Statalist The Stata Listserver


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

Re: st: RE: Loess confidence bands


From   "Paswel Phiri Marenya" <ppm3@cornell.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: Loess confidence bands
Date   Wed, 7 Mar 2007 17:53:55 -0500 (EST)

Dear Austin:
This is very helpful.

I have tried to use these lines and get the message:
''insufficient obervations to compute bootstrap standard errors''

 One question. My data has 445 rows, with GPS code identifiers. How do I
modify the pr eachone, bsample commands to suit this situation. Dioes
this have something to do with the number of rows? or the way x is
generated here?

Thanks
Paswel


> Paswel Phiri Marenya asked:
>> > How do I get confidence bands around my -lowess- graphs?
>
> This example may be a useful starting point
> (note I use -locpoly- rather than -lowess-, but the idea is the same):
>
> net inst st0053_3, replace
> webuse nlswork, clear
> gen work=wks_w>0 if !mi(wks_w)
> keep work age id
> save /out, replace
>
> cap pr drop _all
> pr eachone, rclass
> drop _all
> use /out
> bsample, cluster(idcode)
> gen x=_n in 20/40
> locpoly work age, gen(sm) at(x) nog
> forv a=20/40 {
>  return scalar a`a'=sm[`a']
> }
> end
>
> gen x=_n in 20/40
> locpoly work age, gen(sm) at(x) nog
> qui reg work age
> local n=e(N)
> local rownames
> local rnames
> forv a=20/40 {
>  mat a=nullmat(a) , `=sm[`a']'
>  local rownames `rnames' a`a'
>  local rnames "`rnames' a`a'=r(a`a')"
> }
> simulate `rnames', reps(10) seed(12345): eachone
> bstat, stat(a) n(`n')
> mat b=e(b)
> mat v=e(V)
> drop _all
> set obs 21
> gen coef=.
> gen ll=.
> gen ul=.
> forv i=1/21 {
>  qui replace coef=b[1,`i'] in `i'
>  qui replace ll=b[1,`i']-1.96*sqrt(v[`i',`i']) in `i'
>  qui replace ul=b[1,`i']+1.96*sqrt(v[`i',`i']) in `i'
> }
> g a=_n+19
> la var a "Age in years"
> tw rarea ll ul a || line coef a, leg(lab(1 "CI") lab(2 "Working"))
> *
> *   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/



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