third class log.log
log type: text
opened on: 3 Oct 2005, 10:55:40
. edit
(3 vars, 4 obs pasted into editor)
- preserve
. desmat: poisson count color live, verbose
Desmat generated the following design matrix:
nr Variables Term Parameterization
First Last
1 _x_1 color ind(1)
2 _x_2 live ind(1)
Iteration 0: log likelihood = -9.5395876
Iteration 1: log likelihood = -9.5395873
Poisson regression Number of obs = 4
LR chi2(2) = 9.58
Prob > chi2 = 0.0083
Log likelihood = -9.5395873 Pseudo R2 = 0.3342
------------------------------------------------------------------------------
count | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_x_1 | -.6931472 .244949 -2.83 0.005 -1.173238 -.213056
_x_2 | .2411621 .2326211 1.04 0.300 -.2147668 .6970909
_cons | 3.091042 .1922751 16.08 0.000 2.71419 3.467895
------------------------------------------------------------------------------
Poisson regression
--------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 4
Initial log likelihood: -14.328
Log likelihood: -9.540
LR chi square: 9.578
Model degrees of freedom: 2
Pseudo R-squared: 0.334
Prob: 0.008
------------------------------------------------------------------------------------------
nr Effect Coeff s.e.
------------------------------------------------------------------------------------------
count
color
1 Green -0.693** 0.245
live
2 Water 0.241 0.233
3 _cons 3.091** 0.192
------------------------------------------------------------------------------------------
* p < .05
** p < .01
. set linesize 79
. *note that the lr chisquare at the top of every output tests the current model against the constant only model. See My Excel File for a summary of this.
. poisson count
Iteration 0: log likelihood = -14.328367
Iteration 1: log likelihood = -14.328367 (backed up)
Poisson regression Number of obs = 4
LR chi2(0) = -0.00
Prob > chi2 = .
Log likelihood = -14.328367 Pseudo R2 = -0.0000
------------------------------------------------------------------------------
count | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_cons | 2.931194 .1154701 25.38 0.000 2.704877 3.157511
------------------------------------------------------------------------------
. predict const_only
(option n assumed; predicted number of events)
. table color live, contents (mean const_only)
------------------------
| live
Color | Lilly Water
----------+-------------
Blue | 18.75 18.75
Green | 18.75 18.75
------------------------
. poisgof
Goodness-of-fit chi2 = 9.822078
Prob > chi2(3) = 0.0201
. *This goodness of fit test indicates that the actual data could have been
generated from the constant only model with a probability of 0.02,
or in other words this much deviation from uniformity could be expected 2% of the time.
.
. *now a quick look at what the dummy variables themselves look like
. desmat: poisson count color*live, verbose
Desmat generated the following design matrix:
nr Variables Term Parameterization
First Last
1 _x_1 color ind(1)
2 _x_2 live ind(1)
3 _x_3 color.live ind(1).ind(1)
Iteration 0: log likelihood = -9.417463
Iteration 1: log likelihood = -9.4173319
Iteration 2: log likelihood = -9.4173319
Poisson regression Number of obs = 4
LR chi2(3) = 9.82
Prob > chi2 = 0.0201
Log likelihood = -9.4173319 Pseudo R2 = 0.3427
------------------------------------------------------------------------------
count | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_x_1 | -.8329091 .3787852 -2.20 0.028 -1.575315 -.0905037
_x_2 | .1603427 .2837522 0.57 0.572 -.3958014 .7164867
_x_3 | .2451225 .497174 0.49 0.622 -.7293206 1.219566
_cons | 3.135494 .2085144 15.04 0.000 2.726813 3.544175
------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Poisson regression
-------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 4
Initial log likelihood: -14.328
Log likelihood: -9.417
LR chi square: 9.822
Model degrees of freedom: 3
Pseudo R-squared: 0.343
Prob: 0.020
-------------------------------------------------------------------------------
nr Effect Coeff s.e.
-------------------------------------------------------------------------------
count
color
1 Green -0.833* 0.379
live
2 Water 0.160 0.284
color.live
3 Green.Water 0.245 0.497
4 _cons 3.135** 0.209
-------------------------------------------------------------------------------
* p < .05
** p < .01
. poisgof
Goodness-of-fit chi2 = 7.95e-06
Prob > chi2(0) = .
. table color live, contents (mean _x_1)
------------------------
| live
Color | Lilly Water
----------+-------------
Blue | 0 0
Green | 1 1
------------------------
. table color live, contents (mean _x_2)
------------------------
| live
Color | Lilly Water
----------+-------------
Blue | 0 1
Green | 0 1
------------------------
. table color live, contents (mean _x_3)
------------------------
| live
Color | Lilly Water
----------+-------------
Blue | 0 0
Green | 0 1
------------------------
. desmat: poisson count color*live=ind(2)*ind(2)
-------------------------------------------------------------------------------
Poisson regression
-------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 4
Initial log likelihood: -14.328
Log likelihood: -9.417
LR chi square: 9.822
Model degrees of freedom: 3
Pseudo R-squared: 0.343
Prob: 0.020
-------------------------------------------------------------------------------
nr Effect Coeff s.e.
-------------------------------------------------------------------------------
count
color
1 Blue 0.588 0.322
live
2 Lilly -0.405 0.408
color.live
3 Blue.Lilly 0.245 0.497
4 _cons 2.708** 0.258
-------------------------------------------------------------------------------
* p < .05
** p < .01
. desmat: poisson count color*live=ind(2)*ind(1)
-------------------------------------------------------------------------------
Poisson regression
-------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 4
Initial log likelihood: -14.328
Log likelihood: -9.417
LR chi square: 9.822
Model degrees of freedom: 3
Pseudo R-squared: 0.343
Prob: 0.020
-------------------------------------------------------------------------------
nr Effect Coeff s.e.
-------------------------------------------------------------------------------
count
color
1 Blue 0.833* 0.379
live
2 Water 0.405 0.408
color.live
3 Blue.Water -0.245 0.497
4 _cons 2.303** 0.316
-------------------------------------------------------------------------------
* p < .05
** p < .01
. *The one interaction term is fundamental,
the choice of comparison categories is arbitrary
. tabulate color live [fweight=count], lrchi2
| live
Color | Lilly Water | Total
-----------+----------------------+----------
Blue | 23 27 | 50
Green | 10 15 | 25
-----------+----------------------+----------
Total | 33 42 | 75
likelihood-ratio chi2(1) = 0.2445 Pr = 0.621
* Remember: the actual data have r*c df, in this case 4.
The independence model has r+c-1 df, or in this case 3.
The difference between them is 1 df.
. exit, clear