Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Constructing a variable from standard deviations


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Constructing a variable from standard deviations
Date   Mon, 22 Nov 2010 09:58:39 +0000 (GMT)

--- 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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index