Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "M.P.J. van Zaal" <Matthias.vanZaal@student.uva.nl> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Constructing a variable from standard deviations |
Date | Mon, 22 Nov 2010 12:54:03 +0100 |
Hi mr. Buis, Thanks for your help. However I have a question: You state that the residual variance is assumed to be constant. This is actually not the case. I have 106 different residual stand deviations. I achieved this by using "predict "nameocc" if "dummyoccupation"==1, resid" to predict the residuals. Now I have 106 different residuals, and when i check tabstat their standard deviations are quite different (varying from 0.18-0.8). The paper i am trying to replicate reports a similar range of standard deviations. I would like to have a variable with 106 "observations" (the standard deviations) so I would like to know how to save these different standard deviations in one variable. Do you think I can construct a variable directly from these standard deviations using this method? Many thanks! ----- Original Message ----- From: Maarten buis <maartenbuis@yahoo.co.uk> Date: Monday, November 22, 2010 11:01 am Subject: Re: st: Constructing a variable from standard deviations To: statalist@hsphsun2.harvard.edu > --- On Mon, 22/11/10, M.P.J. van Zaal wrote: > > The goal of the model is to explain sorting into > > occupations with individual risk preferences. > > > > In the first stage I run a Mincerian wage regression with > > dummies for 106 different occupations. The standard > > deviations of the residuals of this regression is used as > > measure for occupation (earnings) risk. > > > > In the second step I use the standard deviation of the > > residuals as dependent variable in a regression on individual > > characteristics including their risk preference. > > In that case the residual variance is assumed to be constant. > This assumption is often called homoscedasticity. You can > turn it into a variable, but that would be a very boring > variable an you can't use it as a dependent variable as there > will be no variance... > > Below is a possible solution. It estimates a linear regression > model, but it allows for differences in the residual variance > across groups. In the example below I used repair record, in > your case you would probably do that by occupation. Since you > have that many occupations, the estimation often becomes quite > hard, so specifying good starting values can help a lot. So > the example also showed how to get those. > > *---------------------------- begin example ----------------------- > // define linear regression model with non-constant error variance > program drop _all > program define mynormal_lf > version 11 > args lnfj mu ln_sigma > quietly replace `lnfj' = /// > ln(normalden($ML_y1, `mu', exp(`ln_sigma'))) > end > > // open data > sysuse auto, clear > recode rep78 1/2=3 > > // estimate a regular regression, i.e. with constant residual variance > reg mpg weight displacement foreign i.rep78 > > // store parameters for starting values > tempname b0 rmse > matrix `b0' = e(b) // effects in the mu equation > scalar `rmse' = ln(e(rmse)) // constant of the ln_sigma equation > > // specify the model > ml model lf mynormal_lf /// > (mu: mpg = weight displacement foreign i.rep78) /// > (ln_sigma: i.rep78) > > // specify the initial values > ml init `b0' > ml init ln_sigma:_cons = `= `rmse' ' > > // maximize the likelihood > ml maximize > > // predict the residual variances > predict sigma, xb eq(ln_sigma) > replace sigma = exp(sigma) > > // display the residual variances > // the residual variance is constant within each category of rep78 > table rep78, c(mean sigma) > *---------------------------- end example ------------------------- > - > (For more on examples I sent to the Statalist see: > http://www.maartenbuis.nl/example_faq ) > > Hope this helps, > Maarten > > -------------------------- > Maarten L. Buis > Institut fuer Soziologie > Universitaet Tuebingen > Wilhelmstrasse 36 > 72074 Tuebingen > Germany > > http://www.maartenbuis.nl > -------------------------- > > > > > * > * 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/