[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"R.E. De Hoyos" <[email protected]> |

To |
<[email protected]> |

Subject |
st: Re: Question about programming using bootstrap |

Date |
Thu, 15 Sep 2005 16:25:35 +0100 |

Alejandro,

You can estimate the empirical standard errors the scalars your self using the bsample command.

I haven't try the following code but you can work along this lines:

local K=100 //Number of replications

local k=1

preserve

while `k'<=`K' {

bsample

foreach var of local varlist {

tempname mg`var'

scalar mg`var' = sg`var' - s`var'

tempname mg`var'`k'

matrix `mg`var'`k''=mg`var'

if `k'==1 {

matrix `mg`var'=`mg`var'`k''

}

if `k'>1 {

matrix `mg`var''=`mg`var''+`mg`var'`k''

}

restore, preserve

local k=`k'+1

}

local k=1

while `k'<=`K' {

if `k'==1 {

matrix se_mg`var'=(`mg`var'`k'' - (`mg`var''/`K'))'*(`mg`var'`k'' - (`mg`var''/`K'))

}

if `k'>1 {

matrix se_mg`var'=se_mg`var'+(`mg`var'`k'' - (`mg`var''/`K'))'* ///

(`mg`var'`k'' - (`mg`var''/`K'))

}

local k=`k'+1

}

matrix se_mg`var'=se_mg`var'/(`K'-1)

restore

}

I hope this helps,

Rafa

________________________

R.E. De Hoyos

Faculty of Economics

University of Cambridge

CB3 9DE, UK

www.econ.cam.ac.uk/phd/red29/

----- Original Message ----- From: "feldman" <[email protected]>

To: <[email protected]>

Sent: Thursday, September 15, 2005 3:04 PM

Subject: st: Question about programming using bootstrap

Statalisters, I have a question about how to bootstrap a set of variables using a single command. More specifically what I am interested in doing is the following. I create a program that estimates a scalar for a set of variables defined in varlist. I then want to bootstrap that program to obtain the standard errors of each one of the scalars. Nevertheless, I can't find a way to tell Stata to do this using a single command for bootstrap. Below is the relevant part of the code that I am using. I get the bootstrapped standard errors but in a very inefficient way because Stata repeats the bs command for each one of the variables in varlist and that can be extremely time consuming. I want to do this with a single bs command. Thanks, Alejandro P.S. My apologies if this message is repeated. I sent it before from another email account (twice) but it didn't went through after more than 12 hours. _______ program define desc . . . foreach var of local varlist { scalar mg`var' = sg`var' - s`var' } . . . foreach var of local varlist { set seed 5432198 bs "desc `varlist' " mg`var'=mg`var' , rep(`rep') level(`level') } _______________ Alejandro Lopez-Feldman Ph.D. Candidate UC DAVIS Agricultural and Resource Economics * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

* * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Question about programming using bootstrap***From:*"feldman" <[email protected]>

- Prev by Date:
**st: Question about programming using bootstrap** - Next by Date:
**st: Combined Horizontal Box Blots do not line up** - Previous by thread:
**st: Question about programming using bootstrap** - Next by thread:
**st: Combined Horizontal Box Blots do not line up** - Index(es):

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