[R] Bootstraping GAMs: confidence intervals

From: Luis Reino <luisreino_at_isa.utl.pt>
Date: Thu, 24 Jul 2008 11:55:42 +0100

Dear R-Users,

I am trying to apply a bootstrap to a GAM in order to calculate the 95% confidence intervals for a smooth curve obtained by the “plot.gam” function of the mgcv package. Nonetheless, I am getting some difficulties in transposing the results for the graphs. I used the following commands in R, “mgcv” and “boot” packages:

*> attach(bbvc_11Jul08)*

*> model.boot<-function(data,indices){*

*+ sub.data<-data[indices,]*


*+ coef(model)}*

*> gam.boot<-boot(bbvc_11Jul08,model.boot,R=1000)*


boot(data = bbvc_11Jul08, statistic = model.boot, R = 1000)

Bootstrap Statistics :

original bias std. error

t1* 0.40370112 0.0002762674 0.02017378

t2* 0.04715501 -0.0144132280 0.07648348

t3* 0.14590936 -0.0135820501 0.05161244

t4* 0.13520098 -0.0096405733 0.04470793

I obtained 4 indexes in the “bootstrap” output. I know that for a lm function, with an independent variable, t1 is the index of the intercept and t2 is the index of the variable, but for GAMs I don't find what each indexes really mean!
Moreover, to calculate the confidence intervals of 95% I proceed as follows:


CALL : boot.ci(boot.out = gam.boot, conf = 0.95)

Intervals :

Level Normal Basic Studentized

95% ( 0.3639, 0.4430 ) ( 0.3635, 0.4434 ) ( 0.3583, 0.4507 )

Level Percentile BCa

95% ( 0.3640, 0.4439 ) ( 0.3623, 0.4434 )

Calculations and Intervals on Original Scale

Warning message:

In sqrt(tv[, 2]) : NaNs produced

My first doubt is when I make "boot.ci", which of the four should I choose? By default, R calculates "index=1:min(2,length(boot.out$t0)" but I don't know if this is the correct form to do it. Finally, I don’t know how to introduce the 95% confidence intervals in the "plot.gam".

I hope you can help me. Thanks in advance.

Luís Reino


Luis Reino, PhD Student
Centro de Estudos Florestais
Departamento de Engenharia Florestal
Instituto Superior de Agronomia
Universidade Técnica de Lisboa
1349-017 Lisboa

R-help_at_r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 24 Jul 2008 - 11:15:51 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 Thu 24 Jul 2008 - 11:32:38 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