[R] Bootstrapping gnls models
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Nov 7 17:11:00 CET 2008
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
More information about the R-help
mailing list