[R] loop question

Thomas thomas.triebs at cantab.net
Tue Apr 5 17:33:11 CEST 2011


Dear all,

I am trying to set up a list with 1:c objects each meant to capture the 
coefficients for one coefficient and 100 replications. I receive the 
following error message:

Error in betaboot[[p]] : subscript out of bounds.

My code is below. Where is my mistake?

Many thanks,

Thomas

_________________________________
betaboot<-list(NULL)

for (i in 1:c) {
betaboot[[i]]<-cbind()
}


num <- 100 # this is the number of bootstraps

for (i in 1:num) {

     [BOOTSTRAP]

   coef.temp <- coef(model.temp, data=newdata)

   for (p in 1:c){
   betaboot[[p]] <- cbind(betaboot[[p]], coef.temp[,p])
   }

   }



More information about the R-help mailing list