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 Stas Kolenikov To statalist@hsphsun2.harvard.edu Subject Re: st: Constructing a variable from standard deviations Date Sun, 21 Nov 2010 18:06:18 -0600

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