# NOT RUN {
## ------------------------------------------------------------
## multivariate regression forests using Mahalanobis splitting
## lipids (all real values) used as the multivariate y
## ------------------------------------------------------------
## load the data
data(nutrigenomic, package = "randomForestSRC")
## multivariate mixed forest call
obj <- rfsrc(get.mv.formula(colnames(nutrigenomic$lipids)),
data.frame(do.call(cbind, nutrigenomic)),
importance=TRUE, nsplit = 10, splitrule = "mahalanobis")
## ------------------------------------------------------------
## plot the standarized performance and VIMP values
## ------------------------------------------------------------
## acquire the error rate for each of the 21-coordinates
## standardize to allow for comparison across coordinates
serr <- get.mv.error(obj, standardize = TRUE)
## acquire standardized VIMP
svimp <- get.mv.vimp(obj, standardize = TRUE)
par(mfrow = c(1,2))
plot(serr, xlab = "Lipids", ylab = "Standardized Performance")
matplot(svimp, xlab = "Genes/Diet/Genotype", ylab = "Standardized VIMP")
## ------------------------------------------------------------
## plot some trees
## ------------------------------------------------------------
plot(get.tree(obj, 1))
plot(get.tree(obj, 2))
plot(get.tree(obj, 3))
## ------------------------------------------------------------
## Compare above to default composite (independent) splitting
## ------------------------------------------------------------
obj2 <- rfsrc(get.mv.formula(colnames(nutrigenomic$lipids)),
data.frame(do.call(cbind, nutrigenomic)),
importance=TRUE, nsplit = 10)
imp <- data.frame(mahalanobis = rowMeans(get.mv.vimp(obj, standardize = TRUE)),
default = rowMeans(get.mv.vimp(obj2, standardize = TRUE)))
print(imp[order(imp["mahalanobis"]), ])
# }
Run the code above in your browser using DataLab