/*this program generates estimates similar to those in Kalist, JHR, 2006. In that paper, the author examines whether higher abortion rates, that presumably reduce the fraction of unwanted children, decrease infanticide rates in the US. The data are state level annual observations from 23 years, 51 state, 1173 observation*/ * state is identified by the state fips code, stfips; * set up capacity constraints; # delimit; set more 1; set memory 20m; set matsize 100; * read in data; use abortion_example; *define log; log using abortion_example.log,replace; * generate the abortion rate, which; * is the fraction of pregnancies that; * end in abortion; gen abort_rate=abortions/(births+abortions); gen birthsl=log(births); * look at distribution of infant homicide; * counts per year; tab homicides; * look at distribution of abort_rate; sum abort_rate, detail; * generate year and state effects; xi i.year i.stfip; * get local list for right hand side variables; local xlist1 abort_rate birthsl popdensity _Iy*; local xlist2 abort_rate birthsl popdensity _Iy* _Ist*; * run a fixed-effect poisson model; * the conditioning variable is stfip; * fe is the option for fixed effects; * can also ask for random effects; xtpoisson homicide `xlist1', i(stfip) fe; * run a negative binomial fixed effects; * the conditioning variable is stfip; xtnbreg homicide `xlist1', i(stfip) fe; * compare to a nbreg model with all the state; * effects added. pick the nbreg model with a ; * constant dispersion factor. in this case; * actively add in state fips; nbreg homicides `xlist2', dispersion(constant); * on shortcoming of the conditional fixed effects and; * negative binomial models is they canot exploit; * correlation in observations within a cluster. for; * mle models, within group correlation is estimated using a; * procedure suggested by liang and zeger; nbreg homicides `xlist2', dispersion(constant) robust cluster(stfip); log close;