Statalist


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

RE: st: confidence intervals for locpoly


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: confidence intervals for locpoly
Date   Mon, 25 Jan 2010 19:59:51 -0000

In that case it is evident that you are using some outdated version of Stata. 

As signalled in the Statalist FAQ, you should say what it is for better advice to be given. 

Nick 
[email protected] 

Sharooon

This works right until the end when I get the error message:

. egen ub = rowpctile(yhat? yhat?? yhat???), p(97.5)
unrecognized command:  _growpctile


I couldn't find rowpctile, so I'm guessing this is pctile, which also doesn't work. I enjoyed your FAQ by the way. Thanks. 

--- On Mon, 1/25/10, Maarten buis <[email protected]> wrote:

> --- On Mon, 25/1/10, Sharooon wrote:
> > I can't get the bootstrap to work with locpoly. 
> 
> If you are using a program that is not part of official
> Stata, then the
> Statalist FAQ askes you to specify where you got. I am
> assuming you are
> using the updated version that appeared in the Stata
> Journal 6(4) (,which
> I found by typing -findit locpoly).
> 
> Below is an example on how to do that. However, you'll want
> to read up 
> on whether the simple bootstrap is appropriate in your
> case, for example
> Chapters 8 and 9 of Efron and Tibshirani (1993). Still,
> even if it 
> doesn't produce meaningfull standard errors/confidence
> intervals, it can
> be used to asses the stability of your estimates, as
> discussed by
> Royston and Sauerbrei in the latest Stata Journal.
> 
> *----------------- begin example ------------------
> 
> sysuse auto, clear
> locpoly mpg weight, nograph  /// 
>         degree(3) width(500) ///
>         generate(xgrid yhat_obs)
> 
> keep if xgrid <.
> keep xgrid yhat_obs
> tempfile tofill
> sort xgrid
> save `tofill'
> gen id = _n
> keep id xgrid
> sort id
> tempfile grid
> save `grid'
> 
> forvalues i = 1/500 {
>     qui {
>         sysuse auto, clear
>         bsample 
>         gen id = _n
>         sort id
>         merge id using
> `grid'
>         drop _merge
>            
> locpoly mpg weight,      ///
>            
> degree(3) width(500) ///
>            
> generate(yhat`i')    ///
>            
> at(xgrid) nograph
>         keep if xgrid < .
>         keep xgrid yhat`i'
>         sort xgrid
>         merge xgrid using
> `tofill'
>         assert _merge == 3
>         drop _merge
>         sort xgrid
>         save `tofill',
> replace
>     }
>     _dots `i' 0
> }
> use `tofill'
> egen lb = rowpctile(yhat? yhat?? yhat???), p(2.5)
> egen ub = rowpctile(yhat? yhat?? yhat???), p(97.5)
> twoway rarea lb ub xgrid || line yhat_obs xgrid
> *------------------ end example ---------------------
> ( For more on how to use examples I sent to statalist see:
>  http://www.maartenbuis.nl/stata/exampleFAQ..html )
> 
> Hope this helps,
> Maarten
> 
> Bradley Efron and Robert J. Tibshirani (1993) An
> Introduction to the 
> Bootstrap. Boca Raton: Chapman & Hall/CRC.
> 
> Patrick Royston and Willi Sauerbrei (2009) Bootstrap
> assessment of the 
> stability of multivariable models. The Stata Journal, 9(4):
> 547–570.
> http://www.stata-journal.com/article.html?article=st0177

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