use http://www3.nd.edu/~rwilliam/statafiles/couart4.dta, clear sum art female married kid5 mentor phd poisson art, nolog estat gof mgen, pr(0/9) meanpred stub(psn) label var psnobeq "Observed Proportion" label var psnpreq "Poisson Prediction" label var psnval "# of articles" list psnval psnobeq psnpreq in 1/10 graph twoway connected psnobeq psnpreq psnval, /// ytitle("Probability") ylabel(0(.1).4) xlabel(0/9) msym(O Th) poisson art i.female i.married kid5 phd mentor, nolog estat gof mgen, pr(0/9) meanpred stub(psn) replace label var psnobeq "Observed Proportion" label var psnpreq "Poisson Prediction" label var psnval "# of articles" list psnval psnobeq psnpreq in 1/10 graph twoway connected psnobeq psnpreq psnval, /// ytitle("Probability") ylabel(0(.1).4) xlabel(0/9) msym(O Th) glm art i.female i.married kid5 phd mentor, family(poisson) link(log) poisson art i.female i.married kid5 phd mentor, nolog irr margins female married margins, dydx(*) mcp mentor female listcoef, help listcoef, help percent mchange set seed 123456 gen profage = (10 + invnorm(uniform())) * 3 if female == 0 set seed 1234567 replace profage = (5 + invnorm(uniform())) * 3 if female == 1 bysort female: sum profage poisson art i.female i.married kid5 phd ment, nolog exposure(profage) irr use http://www3.nd.edu/~rwilliam/statafiles/couart4.dta, clear nbreg art i.female i.married kid5 phd ment, nolog test [lnalpha]_cons = 1 quietly poisson art i.female i.married kid5 phd ment, nolog est store poisson quietly nbreg art i.female i.married kid5 phd ment, nolog est store nbreg lrtest poisson nbreg, stats force est table poisson nbreg, t varlabel varwidth(32) stats(alpha N) b(%9.3f) quietly nbreg art i.female i.married kid5 phd ment margins female married margins, dydx(*) listcoef listcoef, percent * hbnlogit has a bug with irr; the user-written eret2 solves it use http://www3.nd.edu/~rwilliam/statafiles/couart4.dta, clear quietly hnblogit art female married kid5 phd mentor, nolog robust irr eret2 scalar k_eform = 3, replace ml display, irr use http://www.indiana.edu/~jslsoc/stata/spex_data/couart4, clear countfit art i.female i.married kid5 phd mentor, inflate(mentor i.female) replace