[R] bootstrapping error message "Error in t.star[r, ] <- statistic(data, i[r, ], ...) : number of items to replace is not a multiple of replacement length"

Karina Boege kboege at servidor.unam.mx
Wed Jul 8 13:17:54 CEST 2009



Hi,

I am trying to run some bootstraps with the boot package. When I run 
it with 400 replicates it does it ok, but then I need to run the same 
analysis but with 89, 86, 102 and 106 samples (for four different 
environments), and then is when I get the error message:

 > mybootstrap <- boot(Datos, mystat, 2000)
Error in t.star[r, ] <- statistic(data, i[r, ], ...) :  number of 
items to replace is not a multiple of replacement length

Anyone familiar with this error message?
Does anyone knows the minimum sample size for boot package to run 
properly? Is there anyway to tell R how many samples should it pick 
for the resampling?

If it helps, this is how my model looks like:

mymodel = lm(Datos[,4]~Datos[,1]+ 
Datos[,8]+Datos[,9]+Datos[,10]+Datos[,11]+Datos[,12])
summary(mymodel)

mystat <- function(a,b)
f<- lm(a[b,4]~a[b,1]+a[b,8]+ a[b,9]+a[b,10]+a[b,11]+a[b,12])$coef

mybootstrap <- boot(Datos, mystat, 2000)

INT1<-boot.ci(mybootstrap, conf=0.95, type="all", index=1)
INT2<-boot.ci(mybootstrap, conf=0.95, type="all", index=2)
INT3<-boot.ci(mybootstrap, conf=0.95, type="all", index=3)
INT4<-boot.ci(mybootstrap, conf=0.95, type="all", index=4)
INT5<-boot.ci(mybootstrap, conf=0.95, type="all", index=5)
INT6<-boot.ci(mybootstrap, conf=0.95, type="all", index=6)
INT7<-boot.ci(mybootstrap, conf=0.95, type="all", index=7)


Thanks for your help! I am new to bootstraps and to R, and I feel 
pretty lonely with this

Karina Boege




More information about the R-help mailing list