Re: [R] Bootstrapping gnls models

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri, 07 Nov 2008 16:11:00 +0000 (GMT)

On Fri, 7 Nov 2008, Christoph Scherber wrote:

> Dear all,
>
> I am trying to bootstrap predictions from gnls models using the following
> code:
>
> # a is the dataframe with which I am working; it contains the variables
> # response.variable,LD,L,G,P and F

And without it your code is not reproducible.

>
> ###
>
> model=gnls(response.variable ~ a * LD/(b + LD),
> params = list(a + b ~ L), start = c(1,1,1,1), data=a)
>
> df=cbind(a,fit=predict(model,list(LD=1,L=0.5,G=0.5,P=0.46,F=2.2)))
> model.bootfunc=function(rs,i){
> df$response.variable=df$fit+rs[i]
> as.numeric(predict(gnls(response.variable ~ a * LD/(b + LD),
> params = list(a + b ~ L), start = coef(model), data=df)))
> }
>
> rs=scale(resid(model),scale=F)
> (model.boot=boot(rs,model.bootfunc,R=1))
> booted=boot.ci(model.boot,index=1,type=c("norm","basic","perc","bca"))

Do please try to make your code readable, using spaces and <- for assignments. I would have spotted the problem much sooner with legible, reproducible code.

> ###
>
> The problem is that this code yields "NA" for the s.e. of the bootstrap
> statistics:
>
> Bootstrap Statistics :
> original bias std. error
> t1* 0.1651658 -0.020663364 NA
> t2* 0.1669592 -0.021759335 NA
> t3* 0.1676765 -0.001858686 NA
> t4* 0.1726982 -0.025321349 NA
> t5* 0.1658092 0.024721214 NA
>
>
> And hence the boot.ci function and others don?t work.
>
> Does anyone have an idea on that?

Yes: how can you estimate standard errors from a single sample (you set R=1)?

> Many thanks and best wishes
> Christoph
>
>
>
> --
> Dr. rer.nat. Christoph Scherber
> University of Goettingen
> DNPW, Agroecology
> Waldweg 26
> D-37073 Goettingen
> Germany
>
> phone +49 (0)551 39 8807
> fax +49 (0)551 39 8806
>
> Homepage http://www.gwdg.de/~cscherb1
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 07 Nov 2008 - 16:15:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 07 Nov 2008 - 17:30:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive