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

# Re: Re: st: Constructing a variable from standard deviations

 From Christopher Baum To "statalist@hsphsun2.harvard.edu" Subject Re: Re: st: Constructing a variable from standard deviations Date Mon, 22 Nov 2010 06:44:10 -0500

```<>
On Nov 22, 2010, at 2:33 AM, M.P. wrote:

> 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.
>
> My problem is that I dont know how i can construct a variable from the
> standard deviations of the residuals. I have the residuals and I know
> how to find their standard deviations (for example with tabstat). I dont
> know how to construct a variable from these (106) standard deviations. I
> have tried tabstat and the egen advice you have me earlier but these
> dont yield good results.

------------------------------
webuse grunfeld, clear
// run a regression for each company, save residuals
g double eps = .
forv i=1/10 {
qui reg invest mvalue kstock if company==`i'
tempvar epsi
qui predict double `epsi' if e(sample), resid
qui replace eps = `epsi' if e(sample)
drop `epsi'
}
tabstat eps, by(company) stat(mean sd)
collapse (sd) eps, by(company)
l company eps
------------------------------

Kit

Kit Baum   |   Boston College Economics & DIW Berlin   |   http://ideas.repec.org/e/pba1.html
An Introduction to Stata Programming  |   http://www.stata-press.com/books/isp.html
An Introduction to Modern Econometrics Using Stata  |   http://www.stata-press.com/books/imeus.html

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