-------------------------------------------------------------------------------
log: C:\AAA Miker Files\current class files\methods tabular arrays\clas
> s 2.smcl
log type: smcl
opened on: 29 Sep 2003, 11:28:55
. tabulate color live [fweight=count]
| Live
Color | Lilly Water | Total
-----------+----------------------+----------
Blue | 23 27 | 50
Green | 10 15 | 25
-----------+----------------------+----------
Total | 33 42 | 75
. *here's our first loglinear model of the class:
. desmat: poisson count color live
--------------------------------------------------------------------------------------------------
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
. *Question is, what does this independence model actually look like?
. predict indep_model
(option n assumed; predicted number of events)
. tabulate color live [fweight= indep_model]
| Live
Color | Lilly Water | Total
-----------+----------------------+----------
Blue | 22 28 | 50
Green | 11 14 | 25
-----------+----------------------+----------
Total | 33 42 | 75
. tabulate live color [fweight= indep_model]
| Color
Live | Blue Green | Total
-----------+----------------------+----------
Lilly | 22 11 | 33
Water | 28 14 | 42
-----------+----------------------+----------
Total | 50 25 | 75
. desmat: poisson count live*color
--------------------------------------------------------------------------------------------------
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
live
1 Water 0.160 0.284
color
2 Green -0.833* 0.379
live.color
3 Water.Green 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) = .
. *This is the saturated model. It has 4 terms, and the dataset has 4 data points. So this model fits the data exactly.
. predict saturated
(option n assumed; predicted number of events)
. table live color, contents (sum count sum saturated)
------------------------
| Color
Live | Blue Green
----------+-------------
Lilly | 23 10
| 23 10
|
Water | 27 15
| 27 15
------------------------
. desmat: poisson count color live
--------------------------------------------------------------------------------------------------
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
. poisgof
Goodness-of-fit chi2 = .2445188
Prob > chi2(1) = 0.6210
. poisgof, pearson
Goodness-of-fit chi2 = .2435065
Prob > chi2(1) = 0.6217
. *These are the two goodness of fit tests for our independence model.
The independence model has 3 df, the actual data have 4df, so there is a difference of 1 df.
The expected value of chisquare(n) is n. Anything less than n mean
> s there is less difference between predicted values and the actual data than
> we would expect by chance.
. *Note that the goodness of fit test comparing the independence model to the s
> aturated model is another, separate kind of test of independence. In this ca
> se both the goodness of fit test (between the independence model and the satu
> rated model) and the significance test for the log odds ratio of interaction
> (from the saturated model) yield the same result: insignificance. That is, t
> he there is no statisically significant difference between the independence m
> odel and the actual data.
. log close
log: C:\AAA Miker Files\current class files\methods tabular arrays\clas
> s 2.smcl
log type: smcl
closed on: 29 Sep 2003, 12:19:13
------------------------------------------------------------------------------