Statalist


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

Re: st: Re: what does -egen std- do?


From   Caleb Southworth <caleb@uoregon.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re: what does -egen std- do?
Date   Wed, 1 Apr 2009 13:15:41 -0700 (PDT)

Thanks. That settles it. CS. 

On Wed, 1 Apr 2009, Martin Weiss wrote:

:<>
:
:That is a rounding error b/c you transferred the mean and sd by hand....
:
:****
:clear*
:set obs 10000
:g x =rnormal()
:su x
:g x1=(x-r(mean))/r(sd)
:egen x2=std(x)
:su x?
:*****
:
:In the example, both results match...
:
:
:HTH
:Martin _______________________
:----- Original Message ----- From: "Caleb Southworth" <caleb@uoregon.edu>
:To: <statalist@hsphsun2.harvard.edu>
:Sent: Wednesday, April 01, 2009 10:05 PM
:Subject: st: what does -egen std- do?
:
:
:> How is the variable generated by -egen std- standardized?
:> 
:> Here I take a variable, subtract the mean and divided by sd
:> 
:> gen std_man=(P_math-45.20336)/13.3137
:> 
:> Here's the egen version
:> 
:> egen std_egn=std(P_math)
:> 
:> . sum std*
:> 
:>     Variable |       Obs        Mean    Std. Dev.       Min        Max
:> -------------+--------------------------------------------------------
:>      std_man |       775    2.58e-07    .9999999  -3.019699    3.06426
:>      std_egn |       775   -1.24e-09           1  -3.019699    3.06426
:> 
:> What explains the difference in means?
:> 
:> Caleb Southworth
:> Associate Professor
:> Univ. of Oregon Sociology
:> *
:> *   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/
:

Caleb Southworth
Associate Professor
Univ. of Oregon Sociology
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index