Bookmark and Share

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

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

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

From   Christopher Baum <>
To   "" <>
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 Baum   |   Boston College Economics & DIW Berlin   |
                              An Introduction to Stata Programming  |
   An Introduction to Modern Econometrics Using Stata  |

*   For searches and help try:

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