I need to conduct an analyses where we need to do apply a GBM algorithm onto a series of bootstrapped replicates. Another wrinkle is that each replicate needs to have a quantile normalized outcome. What I am trying to eventually achieve is 1. Start with main data set with 2. Create a 3-dimensional array that contains 200 resamples 3. Quantile normalize the outcome variable within each resample 4. Run a GBM in all samples
Right now, I can't even get to the resampling step.
#generating some data
main<-matrix(
replicate(52,rnorm(1132)),
ncol=52,
nrow=1132,
dimnames = list(
1:1132,
1:52)
)
colnames(main)[1]<-"outcome"
#trying to create 200 resampled replicates
resampled = array (
rep(NA),
dim= c(1000, ncol(main), 200),
dimnames= list(
1:1000,
colnames(main),
1:200
)
)
for (i in 1:dim(resampled)[1]) {
for (j in 1:dim(resampled)[2]) {
for (k in 1:dim(resampled)[3]) {
resampled[i,j,k]= main[sample(nrow(main), size=1000, replace=TRUE),]
}
}}
I'm pretty sure it's because I'm not specifying the loop correctly, but after weeks of searching, I can't find exemplar code that will help me.
I currently get an error message: Error in resampled[i, j, k] = main[sample(nrow(main), size = 1000, replace = TRUE), : number of items to replace is not a multiple of replacement length