I am trying to estimate a censored regression model of expenditures,
where about a third of my observations have a zero value. I transformed the expenditure variable by taking the log and it passed the LM test for normality. I also can't reject the null of homoskedasticity with an auxiliary regression, so I think the statistical assumptions for a tobit are satisfied. I am interested in seeing how the average latent variable prediction of exp depends on the value of the variable x1 and a dummy variable di. I would like to use margins to do something like this: margins, predict(ystar(`e(llopt)',.)) at(x1==(0(10)100)) over(di), but I cannot figure out how to get margins to perform the transformation back to y from ln(y) with the expression() option. Instead, I tried to do the following: /* Trick Stata to handle the log transformation */ gen lny=ln(exp); qui sum lny; scalar gamma=r(min); replace lny = gamma  0.0000001 if lny==.; /* Estimate the model */ tobit lny x1 x2 x3 di, ll; matrix btobit=e(b); scalar sigma=btobit[1,e(df_m)+2]; /* Transform back to E[yx] */ forvalues v=0(10)100 {; replace x1=`v'; predict xb if e(sample), xb; generate yhat`v'=exp(xb+0.5*sigma^2)*(1normal((gammaxbsigma^2)/sigma)); drop xb; }; collapse (mean) yhat*, by(di); Does this accomplish what I think it does? Is there a better way of doing this or estimating that does not require the retransformation business? I don't really have any sensible exclusion restrictions to try a twopart model. Dimitriy * * 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/ 
Greetings
Solely commenting on the use of the expression() option, I wonder if this does what you want... expression(exp(predict(xb))) Best regards, Michael N. Mitchell Data Management Using Stata  http://www.stata.com/bookstore/dmus.html A Visual Guide to Stata Graphics  http://www.stata.com/bookstore/vgsg.html Stata tidbit of the week  http://www.MichaelNormanMitchell.com On 20101117 7.57 PM, Dimitriy V. Masterov wrote: > I am trying to estimate a censored regression model of expenditures, > where about a third of my observations have a zero value. I > transformed the expenditure variable by taking the log and it passed > the LM test for normality. I also can't reject the null of > homoskedasticity with an auxiliary regression, so I think the > statistical assumptions for a tobit are satisfied. > > I am interested in seeing how the average latent variable prediction > of exp depends on the value of the variable x1 and a dummy variable > di. I would like to use margins to do something like this: > > margins, predict(ystar(`e(llopt)',.)) at(x1==(0(10)100)) over(di), > > but I cannot figure out how to get margins to perform the > transformation back to y from ln(y) with the expression() option. > > Instead, I tried to do the following: > > /* Trick Stata to handle the log transformation */ > gen lny=ln(exp); > qui sum lny; > scalar gamma=r(min); > replace lny = gamma  0.0000001 if lny==.; > > /* Estimate the model */ > tobit lny x1 x2 x3 di, ll; > > matrix btobit=e(b); > scalar sigma=btobit[1,e(df_m)+2]; > > /* Transform back to E[yx] */ > forvalues v=0(10)100 {; > replace x1=`v'; > predict xb if e(sample), xb; > generate yhat`v'=exp(xb+0.5*sigma^2)*(1normal((gammaxbsigma^2)/sigma)); > drop xb; > }; > > collapse (mean) yhat*, by(di); > > Does this accomplish what I think it does? Is there a better way of > doing this or estimating that does not require the retransformation > business? I don't really have any sensible exclusion restrictions to > try a twopart model. > > Dimitriy > * > * 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/ * 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/ 
Michael,
That is actually exactly what I was looking for. It somehow never occurred to me to do it all in one step. For posterity's sake, E(YX,Y>0) Margins: margins, expression( exp(predict(xb)+0.5*sigma^2) * (1  normal((gammapredict(xb)sigma^2)/sigma)) * 1/(1normal((gammapredict(xb))/sigma)) ) at(x1=(10(10)100)) over(di); E(YX) Margins: margins, expression( exp(predict(xb)+0.5*sigma^2) * (1  normal((gammapredict(xb)sigma^2)/sigma)) ) at(x1=(10(10)100)) over(di); DVM P.S. I am reading your Stata graphics book right now. It's very helpful and beautiful! * * 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/ 
This post has NOT been accepted by the mailing list yet.
I am also using a log transformed response in a tobit regression. I am trying to replicate Dimitriy's commands in STATA 9 to get ME using the mfx predict command. Does anyone know how to obtain marginal effects for the probability of being uncensored (mfx compute, predict(p(a,b))) with log transformed data?

Powered by Nabble  Edit this page 