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

# Re: st: Constructing a variable from standard deviations

 From "M.P.J. van Zaal" To statalist@hsphsun2.harvard.edu Subject Re: st: Constructing a variable from standard deviations Date Mon, 22 Nov 2010 01:19:57 +0100

```I am sorry for not being very clear. Like I said, im not yet very
experienced in research practice.

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.

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.

I hope my problem is now clear and that you (or other STATA users) can
help me. If you still dont understand it please ask me again :-).

----- Original Message -----
From: Stas Kolenikov <skolenik@gmail.com>
Date: Monday, November 22, 2010 1:09 am
Subject: Re: st: Constructing a variable from standard deviations
To: statalist@hsphsun2.harvard.edu

> I am totally lost. So where are these standard deviations coming from?
>
> On Sun, Nov 21, 2010 at 5:33 AM, M.P.J. van Zaal
> <Matthias.vanZaal@student.uva.nl> wrote:
> > Thanks for your help mr Kolenikov.
> >
> > However, im not sure the tips you gave me adress my problem. I will
> > rephrase in more detail:
> >
> > The goal of my analysis is the examine sorting effects. The standard
> > deviations are measures of risk of different options individuals
> have.> The individuals sort themself in one of those options by
> choosing a
> > risk level of the liking. The 106 standard deviations are thus the
> > different possible "types" of the individuals in the sample.
> > I want to have a variable with the 106 different standard deviations
> > so i can use it as dependent variable in my regression.
> >
> > The 106 standard deviations have ofcourse different frequencies,
> > because some options are more frequently chosen. Do you think i
> should> incorporate this?
> >
> > Anyways, it would be awesome if you can give me some usefull STATA
> > procedures. Other STATAlist users are ofcourse also welcome to give
> >
> > regards,
> >
> > Mathijs (first timer in a real research project involving stata)
> >
> >
> >
> > ----- Original Message -----
> > From: Stas Kolenikov <skolenik@gmail.com>
> > Date: Sunday, November 21, 2010 0:26 am
> > Subject: Re: st: Constructing a variable from standard deviations
> > To: statalist@hsphsun2.harvard.edu
> >
> >> -tabstat- is far from the most appropriate command for this
> purpose.>> There are several ways to achieve what you need.
> >>
> >> 1. Use -egen- command:
> >>
> >> egen sdy = sd( y )
> >>
> >> 2. Use saved results from -summarize- (type -return list- to
> find out
> >> what these are):
> >>
> >> sum y
> >> gen sdy = r(sd)
> >>
> >> I personally think that having a variable equal to a constant is a
> >> data management oxymoron... variable must vary, by the virtue of
> its>> name :). You probably only need it for another step or two in
> data>> analysis, e.g., if you want to simulate a new set of errors
> with the
> >> same variance:
> >>
> >> sum y
> >> gen new_y = rnormal()*r(sd)
> >>
> >> On Sat, Nov 20, 2010 at 9:36 AM, M.P.J. van Zaal
> >> <Matthias.vanZaal@student.uva.nl> wrote:
> >> >
> >> > I have a problem with constructing a new a variable from the
> >> standard> deviations of regressions residuals. I have generated
> >> 104 different
> >> > regression residuals and then use tabstat to determine their
> >> standard> deviations. I need to construct a new variable from
> >> these 104 standard
> >> > deviations of the regression residuals for the next step in my
> >> analysis.>
> >> > I know that the tabstat has a save options to save the summary
> >> > statistics in a matrix. Unfortunately when I use this option no
> >> matrix> is created (nothing happens). Does anyone know how i can
> >> save the
> >> > standard deviations in as a new variable, possible using
> tabstat or
> >> > another method.
> >> >
> >> > Thanks for your attention and help
> >> >
> >> > regards,
> >> >
> >> > Mathijs
> >> > *
> >> > *   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/
> >> >
> >>
> >>
> >>
> >> --
> >> Stas Kolenikov, also found at http://stas.kolenikov.name
> >> Small print: I use this email account for mailing lists only.
> >>
> >> *
> >> *   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/
> >
>
>
>
> --
> Stas Kolenikov, also found at http://stas.kolenikov.name
> Small print: I use this email account for mailing lists only.
>
> *
> *   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/
```