Statalist


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

Re: st: bootstrap command help


From   "Joseph Coveney" <[email protected]>
To   "Statalist" <[email protected]>
Subject   Re: st: bootstrap command help
Date   Sun, 13 Apr 2008 17:32:48 +0900

Swati Misra wrote:

I needed help on command of bootstrap to run the bootstrap on 2 continuous
variables at a time.
I was successful in running the 1000 replications to bootstrap 1 variable at
a time and the command I used was as follows:

[redacted]

Please let me know how to run bootstrap for 2 variables simultaneously.

--------------------------------------------------------------------------------

Have -bootstrap- call a program that you write that does what you want.
You'll need to collect the various statistics in a matrix in order to pass
them out of the called program into -bootstrap-.  Pass the matrix into and
out of the called program in an argument list (option); I don't think that
you can reference an element of a return matrix in-line in an expression
list, i.e., you cannot do:

-bootstrap (price: mean = r(S[1,1]) sd = r(S[1,2]) . . . -

Joseph Coveney

clear *
set more off
*
program define summaries
   version 10
   syntax varlist , container(name)
   tempname R
   foreach var of local varlist {
       quietly summarize `var', detail
       matrix define `R' = nullmat(`R') \ ( r(mean), r(p50), r(sd), ///
         r(p75) - r(p25), r(max) - r(min) )
   }
   matrix colnames `R' = mean median sd iqr range
   matrix rownames `R' = `varlist'
   matrix define `container' = `R'
end
*
tempname A
sysuse auto
set seed `=date("2008-04-13", "YMD")'
bootstrap (price: mean = `A'[1,1] median = `A'[1,2] sd = `A'[1,3] ///
 iqr = `A'[1,4] range = `A'[1,5]) (mpg: mean=`A'[2,1] ///
 median=`A'[2,2] sd = `A'[2,3] iqr = `A'[2,4] ///
 range = `A'[2,5]): summaries price mpg, container(`A')
matrix drop `A'
exit


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



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