global basedir http://personalpages.manchester.ac.uk/staff/mark.lunt global datadir $basedir/stats/9_counts/data use "$datadir/ships.dta", clear label list char type[omit] 5 char built[omit] 4 xi: poisson damage i.type, exposure(months) irr * 1.2 Yes: the LR chi2 is 55.4 on 4 d.f., p = 0.0000 xi: poisson damage i.built, exposure(months) irr * 1.3 Yes: the LR chi2 is 73.10 on 3 d.f., p = 0.0000 xi: poisson damage i.sailed, exposure(months) irr * 1.4 Yes: the LR chi2 is 33.56 on 1 d.f., p = 0.0000 xi: poisson damage i.type i.built i.sailed, exposure(months) irr testparm _Itype* * 1.5 Yes: chi2 = 26.07 on 4 d.f., p = 0.0000 predict pred_n list type built sailed damage pred_n gen diff = abs(damage - pred_n) sort diff list type built sailed damage pred_n diff * 1.6 Type D , built 1970-1974, operated 1975-1979: 11 events observed, 6.18 expected estat gof * 1.7 No, the test is significant, so the observed values are significantly different from the expected values xi: poisson damage i.type*i.built i.sailed, exposure(months) irr testparm _ItypX* * 1.8 No, this term is not significant estat gof * 1.9 The fit of the model is now adequate use $datadir/nbreg, clear xi: poisson deaths i.cohort, exposure(exposure) irr * 2.1 Yes, the rate is lower in cohort 2 than in cohort 1. Cohorts 3 and 1 are not significantly different estat gof * 2.2 The Poisson model was not appropriate xi: nbreg deaths i.cohort, exposure(exposure) irr * 2.3 No, there are no longer any significant differences between the cohorts * 2.4 alpha = 1.81, with a 95\% confidence interval (1.09, 3.00) xi: nbreg deaths i.cohort, exposure(exposure) irr dispersion(constant) *2.5 Yes: delta = 115, with a 95\% confidence interval of (57, 232) * 2.6 Both negative binomial models suggest that there is no effect of cohort xi: nbreg deaths i.age_mos, exposure(exposure) irr * 2.7 Yes: LR chi2 = 88.55 on 6 d.f, p = 0.0000 * 2.8 No, alpha is significantly greater than 0 xi: nbreg deaths i.age_mos i.cohort, exposure(exposure) irr testparm _Ia* testparm _Ic* * 2.9 Yes, both age and cohort are significant predictors in this model * 2.10 No, alpha is no longer significantly greater than 0 (according to the likelihood ratio test) xi: poisson deaths i.age_mos i.cohort, exposure(exposure) irr estat gof * 2.11 Yes, the parameter estimates and standard errors are identical * 2.12 Yes, the goodness of fit test is no longer significant use $datadir/ships xi: poisson damage i.type i.built i.sailed, exposure(months) irr * 3.1 _Itype_4 and _Itype_5. _Ibuilt_4 is quite borderline predict pred_n constraint define 1 _Itype_4 = 0 xi: poisson damage i.type i.built i.sailed, exposure(months) irr const(1) * 3.4 The line for _Itype_4 now has only an entry of 1 for the IRR. The other entries in the table are blank as they no longer make sense: the coeficient was forced to be 0, so it does not have a standard error * The other coefficients have all changed very slightly estat gof * 3.5 The lack of fit in the constrained model is very similar to that in the unconstrained model * There was a bug in stata 8.0 which did not adjust the degrees of freedom * in estat gof when constraints were applied. Therefore your results will have * differed from these. constraint define 2 _Itype_5 = 0 xi: poisson damage i.type i.built i.sailed, exposure(months) irr const(1 2) estat gof * 3.8 the lack of fit has got slightly greater constraint define 3 _Ibuilt_2 = _Ibuilt_3 xi: poisson damage i.type i.built i.sailed, exposure(months) irr const(1 2 3) * 3.9 These lines do have standard errors, confidence intervals etc since they were not constrained to take a specific value * 3.10 They were not constrained to take a specific value estat gof * 3.11 The fit of the model has deteriorated slightly predict pred_cn corr damage pred_n pred_cn * 3.13 The constraints have had little effect on the fit of the model: the correlation between observed and predicted has dropped from 0.9865 to 0.9848 list type built sailed pred_n pred_cn list type built sailed damage pred_n pred_cn * 3.14 There have only been very slight changes in the predicted values clear use $datadir/alligators label list xi: mlogit food i.lake, rrr * 4.2 Yes: LR chi2 = 43.20 on 12 d.f., p = 0.0000 * 4.3 7.9, 10.4 and 4.5 respectively constraint define 1 [Invertebrate]_Ilake_2 = [Invertebrate]_Ilake_3 xi: mlogit food i.lake, rrr const(1) constraint define 2 [Invertebrate]_Ilake_4 = [Invertebrate]_Ilake_3 xi: mlogit food i.lake, rrr const(1 2) * 4.5 The common odds ratio (6.68) lies between the three previous estimates