global basedir http://personalpages.manchester.ac.uk/staff/mark.lunt global datadir $basedir/stats/8_categorical/data use "$datadir/alligators.dta", clear label list gen invertebrate = food - 1 if food < 3 tab invertebrate size, co * 1.3 Of the larger alligators who preferred either fish or invertebrates, 74% preferred fish, compared to 52% of smaller alligators logistic invertebrate size * 1.4 Yes, OR = 0.39, p = 0.008 gen reptile = (food == 3) if (food==3) | food == 1 logistic reptile size * 1.6 No: OR = 2.4, but p = 0.109 mlogit food size, rrr * 1.7 Fish is used as the comparison group * 1.8 The odds ratios are exactly the same, the confidence intervals the same to at least 5 significant figures lincom [Reptile]size - [Invertebrate]size, eform * 1.9 Yes, OR = 6.1, p = 0.002 gen rep_inv = food == 3 if food == 3 | food == 2 logistic rep_inv size, or * 1.10 OR is identical, ci the same to 5 s.f. tabulate food lake, co chi2 * 1.11 There are big differences between the lakes in primary food choice (p = 0.000) * 1.12 7.3% * 1.13 The proportion was much higher in the other lakes mlogit food i.lake, rrr * 1.14 This is highly significant, suggesting that there are big differences between the lakes in food preferences * 1.15 7.92: Yes, the table suggested that preference for invertebrates was lowest in lake Hancock logistic invertebrate i.lake clear use $datadir/politics label list mlogit party race, rrr * 2.2 Blacks are less likely to be republicans rather than democrats when compare to whites * OR = 0.10, p = 0.000 * 2.3 Blacks are less likely to be independents rather than democrats when compare to whites * OR = 0.33, p = 0.000 mlogit party gender, rrr * 2.5 0.56, 95% CI = 0.41, 0.75 mlogit party i.race i.gender, rrr mlogit party i.race##i.gender, rrr testparm i.race#i.gender * 2.7 The interaction terms are not significant. So the effect of race is the same in men and women * Or, equivalently, the effect of gender is the same in blacks and whites clear use $datadir/housing label list ologit satisfaction i.housing * 3.2 Yes: the fit of the model is highly significant (chi2 = 55.6, p = 0.0000) * 3.3 The most satisfied are the ones with the highest coefficent. In this case, this is group 1 (Tower Blocks) ologit satisfaction influence * 3.4 Influence is a highly significant predictor of satisfaction * I have fitted it as a continuous variable, assuming a trend in the effect. * Fitting it as a categorical variable confirms that this is reasonable ologit satisfaction i.influence * The effect of high influence is about twice the effect of medium influence, so are trend model is appropriate ologit satisfaction contact * 3.4 Contact is not a significant predictor of satisfaction ologit satisfaction influence i.housing * 3.5 Influence is still significant after adjusting for housing type (z = 9.84, p= 0.000) testparm i.housing * 3.5 Housing is still significant after adjusting for influence (chi2 = 51, p= 0.0000) ologit satisfaction i.housing##c.influence testparm i.housing#c.influence * 3.6 Yes, the three interaction terms are significant. Influence is of greater importance in housing types 2 and 4 than in housing types 1 and 3