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

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

 From "Martin Weiss" To Subject st: Re: what does -egen std- do? Date Wed, 1 Apr 2009 22:06:52 +0200

```<>

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

 © Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index