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

From |
"Joao Pedro W. de Azevedo" <jazevedo@provide.com.br> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: Bootstrap |

Date |
Fri, 15 Aug 2003 10:52:37 +0100 |

Thanks Nick. I ended up using the matrix operators. But your suggestion is also interesting. Could you have saved this values as locals instead of variables? JP -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: Friday, August 15, 2003 10:32 AM To: statalist@hsphsun2.harvard.edu Subject: RE: st: Bootstrap Jeff Pitblado replied to Joao Pedro W. de Azevedo > > I would like to know how I can save the bootstraped 95% confidence > intervals > > of a mean. It would be best for me to save this either > as a scalar or a > > local, since I will be using these values to generate a > special tabulation > > of several variables. > > The conficence limits are saved in matrices in e(). From > [R] bootstrap: > > e(ci_normal) normal-approximation Conficence limits > e(ci_percent) percentile Conficence limits > e(ci_bc) bias-corrected Conficence limits > e(ci_bca) bias-corrected and accelerated > Conficence limits Joao Pedro then asked > Is there any way that I can see all the available matrixs after the > bootstrap command? I've tried matrix dir, but nothing come up. > What about the mean value? Where is it saved? Yes: you can type -ereturn list-. The mean itself is saved in e(b). As said earlier, given your aim of producing tables, I think you want to get these results into variables as soon as possible. (An alternative would be to populate a matrix, but that is not as general or as flexible.) Here is one approach. It is not the only one, and it certainly is not necessarily the best one. It is based on a guess that you want to do something by groups, which may not be the case at all. It may well be possible to do something like this using Roger Newson's -parmby- or using -statsby-. If so, Roger will no doubt show the way. For this example, I wrote a do-file. The basic idea is to initialise variables to hold results loop over possibilities { run bootstrap get e-class results put them into matrices put them into appropriate variables } prepare variables for table table results First, here is the file: . type joao.do sysuse auto, clear levels rep78, local(levels) gen mean = . gen lower = . gen upper = . qui foreach l of local levels { bootstrap "summarize mpg if rep78 == `l', meanonly" /// r(mean) , reps(1000) mat m = e(b) replace mean = m[1,1] if rep78 == `l' mat ci = e(ci_normal) replace lower = ci[1,1] if rep78 == `l' replace upper = ci[2,1] if rep78 == `l' } format mean lower upper %7.2f noi di _n as txt "{title:Bootstrap confidence limits}" noi tabdisp rep78 if rep78 < ., c(mean lower upper) . ru joao.do Bootstrap confidence limits ---------------------------------------------- Repair | Record | 1978 | mean lower upper ----------+----------------------------------- 1 | 21.00 16.46 25.54 2 | 19.13 16.56 21.69 3 | 19.43 17.95 20.91 4 | 21.67 19.29 24.05 5 | 27.36 22.14 32.59 ---------------------------------------------- Preparing variables so that you can produce your own tables is the main theme of an article "Problems with tables, Part I" to appear next month in the Stata Journal. Nick n.j.cox@durham.ac.uk * * 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/

**Follow-Ups**:**RE: st: Bootstrap***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**RE: st: Bootstrap***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: Re: OSX 10.2.6 crash - STATA 7** - Next by Date:
**RE: st: Bootstrap** - Previous by thread:
**RE: st: Bootstrap** - Next by thread:
**RE: st: Bootstrap** - Index(es):

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