Hello,
This is somewhat a follow-up to "Error with MIM installed command" but
can be read separately and completely on it's own and does not
currently have anything to do with the mim command.
I could not find a sysuse dataset that would allow me to demonstrate
my issue so please indulge me and imagine you had a dataset with:
county identifiers
year
population
Some population values are missing. You posit that population will be
a function of time and time squared and want to fill in missing values
of population that way (this is just a simplified example, please no
comments on this method of doing this, only on the best way to do so,
thank you!). You also want county-specific slopes and intercepts
(different coefficients and constant for each county).
One way to do this would be
gen yearsq=year*year
reg population year yearsq if county==1
predict pop1 if county==1
reg population year yearsq if county==2
predict pop2 if count==2
etc....
But I want to do this in one command. Unfortunately xi: reg i.county
i.county|year i.county|yearsq, doesn't give exactly the right result
because the 'main' effects of year and yearsq are left in the
regression (the uninteracted effects) which we don't want (although
this notation does eliminate the 'main effects' of county, which are
in there anyways).
The user installed command desmat (ssc install desmat) gets around this problem:
desmat: reg population county county.@year county.@yearsq, nocons
predict population_desmat
this will give the same predicted results as the reg and predict for
each state individually.
Is this the best way to do this?
(I may follow up with the best way to do the above command along with
multiple imputation, which was the thrust of my original question, if
it is true the desmat is the only way to do this in one command....)
Thank you for your consideration and time!
Amanda Agan
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/