Skip to content
Prev 163517 / 398506 Next

help on tapply using resample as FUN element

my specific question is:

I am attempting to create a bootstrap procedure for a finite sample using the theory of Rao and Wu, JASA (1988) that replicates within each strata (h) n_h - 1 times. I am able to sample n_h times using an innitial call to the resample function  I suspect that it has to do with providing extra info to the FUN function but this seems to only allow one value i.e tapply(test, class, mean, trim = 0.1)

i want to be able to have a different value of n for each 

sampler <- function(x) 


{  sample(x, replace = T)
        
        
        
}


raoboot <- function (datavar, statavar, weight,  nboot)
{
        i <- 1
sdatavar <- sort(datavar)
sstratavar <- sort(statavar)
sweight <- sort(weight)
 sdatavarwght <- sdatavar*sweight
 stramn <- tapply(sdatavar, sstratavar, mean)
 meanvect <- rep(0, times = nboot)
 while (i < nboot) 
        { #vector of resampled observations
                vectobsrestemp <- tapply(sdatavarwght, sstratavar, resampler)
                vectobsres <- unlist(vectobsrestemp)
        meanvect[i]        <- mean(vectobsres)
i <- i + 1
}
                
        repvectboot <- rep(mean(meanvect), times = i)
        vb <- sum((repvectboot - meanvect)^2)/(i -1)
}
Message-ID: <1514181354.8987711228188169236.JavaMail.root@huron.cs.uoguelph.ca>
In-Reply-To: <1460753558.8987251228188066608.JavaMail.root@huron.cs.uoguelph.ca>