Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: AW: Simulate stepwise: Report coefficients from each replication


From   John Antonakis <john.antonakis@unil.ch>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: AW: Simulate stepwise: Report coefficients from each replication
Date   Mon, 29 Mar 2010 17:07:29 +0200

Sorry....I took bits out of some older code....in fact, the program is the following (where I want to show that stepwise gives nonsense findings, particularly when analyzing data within extreme groups--believe me, people do this and I am commenting on a paper that just did it)--I will run the below four times for each group (though with a bit of programming I guess it is possible to run it one):

clear
set seed 51

capture program drop sim
version 10.1
program define sim, eclass
       drop _all

set obs 272
gen x1=rnormal()
gen x2=rnormal() +.2*x1
gen x3=rnormal() +.3*x1 + .3*x2
gen x4=rnormal() +.2*x1
gen x5=rnormal()
gen x6=rnormal() + .2*x5
gen x7=rnormal() + .5*x5
gen x8=rnormal() + .1*x7
gen x9=rnormal() + .1*x7

generate double e  = 5*rnormal()
generate double u  = sqrt(exp(-2+0.6*x1))*e

gen y = 5+ x1+x2+x3+x4+x5+x6+x7+x8+x9 + 2*u

reg y x*

sort x1
gen x1_count=_n
gen x1_high=1 if _n > 177
replace x1_high=0 if _n <178
gen x1_low=1 if _n < 96
replace x1_low=0 if _n>95

sort x2
gen x2_count=_n
gen x2_high=1 if _n > 177
replace x2_high=0 if _n <178
gen x2_low=1 if _n < 96
replace x2_low=0 if _n>95

gen group="high_high" if x1_high==1 & x2_high==1
replace group="low_low" if x1_low==1 & x2_low==1
replace group="low_high" if x1_low==1 & x2_high==1
replace group="high_low" if x1_high==1 & x2_low==1

stepwise, pr(.2): reg y x1-x9 if group=="low_low"

end

simulate _b _se, reps(20) seed (123) : sim,

Best,
J.

____________________________________________________

Prof. John Antonakis, Associate Dean Faculty of Business and Economics
Department of Organizational Behavior
University of Lausanne
Internef #618
CH-1015 Lausanne-Dorigny
Switzerland

Tel ++41 (0)21 692-3438
Fax ++41 (0)21 692-3305

Faculty page:
http://www.hec.unil.ch/people/jantonakis

Personal page:
http://www.hec.unil.ch/jantonakis
____________________________________________________



On 29.03.2010 17:02, Martin Weiss wrote:
<>

Where exactly do you define -program- "sim"? -simulate- expects a command
after the colon, remember...



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von John Antonakis
Gesendet: Montag, 29. März 2010 16:56
An: statalist@hsphsun2.harvard.edu
Betreff: st: Simulate stepwise: Report coefficients from each replication

I want to highlight the evils of stepwise analysis. However, I am having problems in getting Stata to report the coefficients from each replication --it seems that it only reports the coefficients that are common across replications. Anyone have any ideas?

clear
set seed 51

drop _all

set obs 272
gen x1=rnormal()
gen x2=rnormal() +.2*x1
gen x3=rnormal() +.3*x1 + .3*x2
gen x4=rnormal() +.2*x1
gen x5=rnormal()
gen x6=rnormal() + .2*x5
gen x7=rnormal() + .5*x5
gen x8=rnormal() + .1*x7
gen x9=rnormal() + .1*x7

generate double e  = 5*rnormal()
generate double u  = sqrt(exp(-2+0.6*x1))*e

gen y = 5+ x1+x2+x3+x4+x5+x6+x7+x8+x9 + 2*u

stepwise, pr(.2): reg y x1-x9

end

simulate _b _se, reps(20) seed (123) : sim,

*
*   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   |   Site index