------------------------------------------------------------------------------- log: :acomp hd (2001-02):desktop folder:class 2.log log type: text opened on: 30 Sep 2002, 13:50:28 . edit (3 vars, 4 obs pasted into editor) - preserve . xi: poisson count color live varlist: color: string variable not allowed r(109); . drop all variable all not found r(111); . drop _all . edit (3 vars, 4 obs pasted into editor) - preserve . xi: poisson count color live Iteration 0: log likelihood = -9.5395876 Iteration 1: log likelihood = -9.5395873 Poisson regression Number of > obs = 4 LR chi2(2) > = 9.58 Prob > chi > 2 = 0.0083 Log likelihood = -9.5395873 Pseudo R2 > = 0.3342 ------------------------------------------------------------ > ------------------ count | Coef. Std. Err. z P>|z| [9 > 5% Conf. Interval] -------------+---------------------------------------------- > ------------------ color | -.6931472 .244949 -2.83 0.005 -1. > 173238 -.213056 live | .2411621 .2326211 1.04 0.300 -.2 > 147668 .6970909 _cons | 3.091042 .1922751 16.08 0.000 2 > .71419 3.467895 ------------------------------------------------------------ > ------------------ . xi: poisson count color live 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] -------------+---------------------------------------------------------------- color | -.6931472 .244949 -2.83 0.005 -1.173238 -.213056 live | .2411621 .2326211 1.04 0.300 -.2147668 .6970909 _cons | 3.091042 .1922751 16.08 0.000 2.71419 3.467895 ------------------------------------------------------------------------------ . predict noint (option n assumed; predicted number of events) . table color live, contents (sum count) ---------------------- | live Color | 0 1 ----------+----------- 0 | 23 27 1 | 10 15 ---------------------- . table color live, contents (sum noint) ---------------------- | live Color | 0 1 ----------+----------- 0 | 22 28 1 | 11 14 ---------------------- . table live color, contents (sum count) ---------------------- | Color live | 0 1 ----------+----------- 0 | 23 10 1 | 27 15 ---------------------- . label define livelab 0 "lillypad" 1 "water" . label val live livelab . label define colorlab 0 "blue" 1 "green" . label val color colorlab . table live color, contents (sum count) ------------------------ | Color live | blue green ----------+------------- lillypad | 23 10 water | 27 15 ------------------------ . table live color, contents (sum noint) ------------------------ | Color live | blue green ----------+------------- lillypad | 22 11 water | 28 14 ------------------------ . *The point I'm making here is that the nointeraction model is exactly the sam > e as the no interaction model we created by hand by multiplying row percentag > es by column percentages. . xi i.color*i.live i.color _Icolor_0-1 (naturally coded; _Icolor_0 omitted) i.live _Ilive_0-1 (naturally coded; _Ilive_0 omitted) i.color*i.live _IcolXliv_#_# (coded as above) . table live color, contents (mean _Icolor_1) ------------------------ | Color live | blue green ----------+------------- lillypad | 0 1 water | 0 1 ------------------------ . table live color, contents (mean _Ilive_1) ------------------------ | Color live | blue green ----------+------------- lillypad | 0 0 water | 1 1 ------------------------ . table live color, contents (mean _IcolXliv_1_1) ------------------------ | Color live | blue green ----------+------------- lillypad | 0 0 water | 0 1 ------------------------ . save ":AComp HD (2001-02):Save Stuff Here (Temporary):frog.dta" file :AComp HD (2001-02):Save Stuff Here (Temporary):frog.dta saved . poisson count _Icolor_1 _Ilive_1 _IcolXliv_1_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] -------------+---------------------------------------------------------------- _Icolor_1 | -.8329091 .3787852 -2.20 0.028 -1.575315 -.0905037 _Ilive_1 | .1603427 .2837522 0.57 0.572 -.3958014 .7164867 _IcolXliv_~1 | .2451225 .497174 0.49 0.622 -.7293206 1.219566 _cons | 3.135494 .2085144 15.04 0.000 2.726813 3.544175 ------------------------------------------------------------------------------ . poisgof Goodness-of-fit chi2 = 7.95e-06 Prob > chi2(0) = . . *This is the saturated model, meaning it fits the data exactly, therefore the > re are NO residual degrees of freedom. . predict saturated (option n assumed; predicted number of events) . table live color, contents (sum saturated) ------------------------ | Color live | blue green ----------+------------- lillypad | 23 10 water | 27 15 ------------------------ . poisson count _Icolor_1 _Ilive_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] -------------+---------------------------------------------------------------- _Icolor_1 | -.6931472 .244949 -2.83 0.005 -1.173238 -.213056 _Ilive_1 | .2411621 .2326211 1.04 0.300 -.2147668 .6970909 _cons | 3.091042 .1922751 16.08 0.000 2.71419 3.467895 ------------------------------------------------------------------------------ . poisgof Goodness-of-fit chi2 = .2445188 Prob > chi2(1) = 0.6210 . *This is the independence, or no- interaction model, it uses 3 terms and leav > es one residual degree of freedom, according to the goodness of fit chisquare > test. This test shows that the no-interaction model fits the data fairly we > ll, which is consistent with our finding that the interaction coefficient in > the saturated is not significant . sysdir set STBPLUS ":AComp HD (2001-02):Applications:Stata (optional):Stata:a > do:stbplus:" . *That's the command that we'll need to keep typing in on the Meyer library Ma > cs in order to use desmat . desmat: poisson count color live ------------------------------------------------------------------------------- poisson ------------------------------------------------------------------------------- Dependent variable count 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 . *That's the 3-term independence model . poisgof Goodness-of-fit chi2 = .2445188 Prob > chi2(1) = 0.6210 . desmat: poisson count color*live ------------------------------------------------------------------------------- poisson ------------------------------------------------------------------------------- Dependent variable count 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 . save ":AComp HD (2001-02):Save Stuff Here (Temporary):frog.dta", replace file :AComp HD (2001-02):Save Stuff Here (Temporary):frog.dta saved . poisgof Goodness-of-fit chi2 = 7.95e-06 Prob > chi2(0) = . . *Again, the saturated model has 4 terms, leaves no residual degrees of freedo > m . exit, clear