Statalist


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

Re: st: AW: can I get standardized coefficients by standardize variables first?


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   Re: st: AW: can I get standardized coefficients by standardize variables first?
Date   Tue, 3 Mar 2009 20:54:56 +0100

<>

Mandy,

try the code below to see how the solutions drift apart depending on the percentage of missings that you introduce into the dataset. ( I know my method is crude but illustrates the issue quite well). Set the thing to zero to see that w/o missings the solutions coincide.


**********
clear*
set mem 400m
* enter the percentage of missings here
loc mis 0.01
u http://www.stata-press.com/data/imeus/traffic, clear
foreach var of varlist fatal beertax spircons unrate perincK {
replace `var'=. if runiform()<`mis'
}
qui ds, not(type string)
foreach var of varlist `r(varlist)'{
egen std`var'=std(`var')
}
xi: reg fatal beertax spircons unrate perincK i.state, beta
xtreg stdfatal stdbeertax stdspircons stdunrate stdperincK, fe
**********


HTH
Martin
_______________________
----- Original Message ----- From: "Mandy fu" <[email protected]>
To: <[email protected]>
Sent: Tuesday, March 03, 2009 8:22 PM
Subject: Re: st: AW: can I get standardized coefficients by standardize variables first?


Dear Mr. Weiss,

Thanks for your reply!  You are right---it should be -foreach-- rather
than --local--.
What I meant and actually used is using --foreach--to standardize all
the variables. I don't know why I wrote into -local--. Thanks!

I think I kind of find why the results given by the two methods are
different. It maybe is due to missing values. That is, for some groups
, there are missing values for some years and for some indepent
variables.
------------------------------
group   year        y   var1  var2          var 3     var4
1           1981      1     1     missing      0           1
1           1982
1           1983
2           1981
2           1982
3           1981
3           1982
3           1983
------------------------------------
For the first observation, it's included in the way "standardizing
varaibles first" because y , var1,var3-4 included this observation.
But it's excluded from the way "using beta option directly".

So, can I underdtand  that it is an alternative way to get beta
coefficents by standardized variables first and then use the regular
commands? This is the question I'm interested in.

Thanks a lot!
Mandy
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index