I am using the randomForest package in R to model imbalanced data. The outcome is a binary variable with the outcome (no, yes) having relative frequencies of (2249(88%), 318 (12%) ).
Due to the imbalance, RF initially predicted no with an OOB error rate of 0% and yes with an OOB error rate of 100%. I changed the sampling design in RF by forcing use of all 318 yes outcomes and 318 no outcomes randomly sampled from a possible 2249 with the following code. The OOB error rates changed to a reasonable 44% for no and 12% for yes.
rf1 <- randomForest(binary.outcome ~ ., data = data,
strata = data$binary.outcome,
sampsize = c(318,318), replace = TRUE, importance = TRUE,
proximity = TRUE, mtry = 8, ntree = 2000)
Does anyone know how to repeat this sampling design but in randomForestSRC?
I am having trouble working it out from the CRAN pdf specifications
rfsrc.1 <- rfsrc(binary.outcome ~ ., data = data,
bootstrap = "by.user", samptype = "swor",
samp = c(318,318), replace = TRUE, importance = "permute",
proximity = TRUE, mtry = 8, ntree = 2000)
I get the error message " in apply(samp,2, sum): dim(x) must have positive length"
I can't work out how to manipulate samp and bootstrap to get what I want.
Thank you,
Don