Hi'
S+ 4.5 R.2, Win2K
I have a number, say n, of r*j matrices, each representing a sampling unit.
I want to bootstrap them, i.e apply a function to the sum of the matrices.
The matrices have been "cbinded" into a big r*(n*j) matrix dat, which is
used as the argument for the "bootstrap func.
boot.fun<-function(bdat){
....
#First pick out which matrices to use for the bootstrap sample by
boot.idx_sample(n,n,T)
#next pick out the matrices and pool them by
boot.dat<-matrix(apply(sapply(j*boot.idx-(j-1),function(i,locdat){locdat[,i:
(i+4)]},bdat),1,sum),ncol=j)
...
}
The code works fine from the commandline, but when called within the
boot.fun from by
bootstrap(dat,boot.fun)
I get the message : Error in [: Need 2 subscripts for array: .Dim=c(36, ..)
(r=36)
Hope someone can explain to me what goes wrong.
Another question: The manual and helpfile say that the data argument to the
bootstrap function must be a vector, a matrix or a dataframe. Does bootstrap
not accept arrays (3 dimensional) ?
Thanks in advance
Rene
*****************************************
René Holst
ConStat
Groenspættevej 10
DK-9800 Hjoerring
Denmark
Tel: +45 98 92 19 79
Mob: +45 24 40 79 41
Fax: +45 98 92 19 56
Web: http://www.constat.dk
SMS: 24407941@sms.tdm.dk (max 160 characters)
*****************************************
|