R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("varSelRF-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('varSelRF') Loading required package: randomForest randomForest 4.5-12 Type rfNews() to see new features/changes/bug fixes. > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "basicClusterInit" > > ### * basicClusterInit > > flush(stderr()); flush(stdout()) > > ### Name: basicClusterInit > ### Title: Initialize a cluster of workstations > ### Aliases: basicClusterInit > ### Keywords: programming > > ### ** Examples > > ## Create a simple cluster with only one slave node. Will work even > ## in 1 CPU cases if you have the required packages. > ## Not run: > ##D basicClusterInit(clusterNumberNodes = 1, > ##D nameCluster = "TheCluster", > ##D typeCluster = "MPI") > ## End(Not run) > > > > cleanEx(); ..nameEx <- "plot.varSelRF" > > ### * plot.varSelRF > > flush(stderr()); flush(stdout()) > > ### Name: plot.varSelRF > ### Title: Plot a varSelRF object > ### Aliases: plot.varSelRF > ### Keywords: tree classif > > ### ** Examples > > x <- matrix(rnorm(25 * 30), ncol = 30) > x[1:10, 1:2] <- x[1:10, 1:2] + 2 > cl <- factor(c(rep("A", 10), rep("B", 15))) > > rf.vs1 <- varSelRF(x, cl, ntree = 200, ntreeIterat = 100, + vars.drop.frac = 0.2) > rf.vs1 Backwards elimination on random forest; ntree = 200 ; mtryFactor = 1 Selected variables: [1] "v1" "v2" Number of selected variables: 2 > plot(rf.vs1) Hit to see next plot: Hit to see next plot: > > cleanEx(); ..nameEx <- "plot.varSelRFBoot" > > ### * plot.varSelRFBoot > > flush(stderr()); flush(stdout()) > > ### Name: plot.varSelRFBoot > ### Title: plot a varSelRFBoot object > ### Aliases: plot.varSelRFBoot > ### Keywords: tree classif > > ### ** Examples > > ## Not run: > ##D ## This is a small example, but can take some time. > ##D > ##D x <- matrix(rnorm(25 * 30), ncol = 30) > ##D x[1:10, 1:2] <- x[1:10, 1:2] + 2 > ##D cl <- factor(c(rep("A", 10), rep("B", 15))) > ##D > ##D rf.vs1 <- varSelRF(x, cl, ntree = 200, ntreeIterat = 100, > ##D vars.drop.frac = 0.2) > ##D rf.vsb <- varSelRFBoot(x, cl, > ##D bootnumber = 10, > ##D usingCluster = FALSE, > ##D srf = rf.vs1) > ##D rf.vsb > ##D summary(rf.vsb) > ##D plot(rf.vsb) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "randomVarImpsRF" > > ### * randomVarImpsRF > > flush(stderr()); flush(stdout()) > > ### Name: randomVarImpsRF > ### Title: Variable importances from random forest on permuted class labels > ### Aliases: randomVarImpsRF > ### Keywords: tree classif > > ### ** Examples > > > x <- matrix(rnorm(45 * 30), ncol = 30) > x[1:20, 1:2] <- x[1:20, 1:2] + 2 > cl <- factor(c(rep("A", 20), rep("B", 25))) > > rf <- randomForest(x, cl, ntree = 200, importance = TRUE) > rf.rvi <- randomVarImpsRF(x, cl, + rf, + numrandom = 20, + usingCluster = FALSE) Obtaining random importances .................... > > randomVarImpsRFplot(rf.rvi, rf) > > > > cleanEx(); ..nameEx <- "randomVarImpsRFplot" > > ### * randomVarImpsRFplot > > flush(stderr()); flush(stdout()) > > ### Name: randomVarImpsRFplot > ### Title: Plot random random variable importances > ### Aliases: randomVarImpsRFplot > ### Keywords: tree classif > > ### ** Examples > > > x <- matrix(rnorm(45 * 30), ncol = 30) > x[1:20, 1:2] <- x[1:20, 1:2] + 2 > cl <- factor(c(rep("A", 20), rep("B", 25))) > > rf <- randomForest(x, cl, ntree = 200, importance = TRUE) > rf.rvi <- randomVarImpsRF(x, cl, + rf, + numrandom = 20, + usingCluster = FALSE) Obtaining random importances .................... > > randomVarImpsRFplot(rf.rvi, rf) > > > > cleanEx(); ..nameEx <- "selProbPlot" > > ### * selProbPlot > > flush(stderr()); flush(stdout()) > > ### Name: selProbPlot > ### Title: Selection probability plot for variable importance from random > ### forests > ### Aliases: selProbPlot > ### Keywords: tree classif > > ### ** Examples > > ## This is a small example, but can take some time. > > x <- matrix(rnorm(25 * 30), ncol = 30) > x[1:10, 1:2] <- x[1:10, 1:2] + 2 > cl <- factor(c(rep("A", 10), rep("B", 15))) > > rf.vs1 <- varSelRF(x, cl, ntree = 200, ntreeIterat = 100, + vars.drop.frac = 0.2) > rf.vsb <- varSelRFBoot(x, cl, + bootnumber = 10, + usingCluster = FALSE, + srf = rf.vs1) Warning in varSelRFBoot(x, cl, bootnumber = 10, usingCluster = FALSE, srf = rf.vs1) : Using as ntree and mtryFactor the parameters obtained from srf Running bootstrap iterations.......... .632+ prediction error 0.1083 > selProbPlot(rf.vsb, k = c(5, 10), legend = TRUE, + xlegend = 8, ylegend = 0.8) Warning in selProbPlot(rf.vsb, k = c(5, 10), legend = TRUE, xlegend = 8, : You only used 10 bootstrap samples. Might be too few. > > > > > cleanEx(); ..nameEx <- "summary.varSelRFBoot" > > ### * summary.varSelRFBoot > > flush(stderr()); flush(stdout()) > > ### Name: summary.varSelRFBoot > ### Title: Summary of a varSelRFBoot object > ### Aliases: summary.varSelRFBoot > ### Keywords: tree classif > > ### ** Examples > > ## Not run: > ##D ## This is a small example, but can take some time. > ##D > ##D x <- matrix(rnorm(25 * 30), ncol = 30) > ##D x[1:10, 1:2] <- x[1:10, 1:2] + 2 > ##D cl <- factor(c(rep("A", 10), rep("B", 15))) > ##D > ##D rf.vs1 <- varSelRF(x, cl, ntree = 200, ntreeIterat = 100, > ##D vars.drop.frac = 0.2) > ##D rf.vsb <- varSelRFBoot(x, cl, > ##D bootnumber = 10, > ##D usingCluster = FALSE, > ##D srf = rf.vs1) > ##D rf.vsb > ##D summary(rf.vsb) > ##D plot(rf.vsb) > ## End(Not run) > > > > > cleanEx(); ..nameEx <- "varSelImpSpecRF" > > ### * varSelImpSpecRF > > flush(stderr()); flush(stdout()) > > ### Name: varSelImpSpecRF > ### Title: Variable selection using the "importance spectrum" > ### Aliases: varSelImpSpecRF > ### Keywords: tree classif > > ### ** Examples > > x <- matrix(rnorm(45 * 30), ncol = 30) > x[1:20, 1:2] <- x[1:20, 1:2] + 2 > cl <- factor(c(rep("A", 20), rep("B", 25))) > > rf <- randomForest(x, cl, ntree = 200, importance = TRUE) > rf.rvi <- randomVarImpsRF(x, cl, + rf, + numrandom = 20, + usingCluster = FALSE) Obtaining random importances .................... > varSelImpSpecRF(rf, randomImps = rf.rvi) Using the randomVarImpsRF rf.rvi object. xdata, Class, numrandom ignored. [1] 1 2 > > > > > cleanEx(); ..nameEx <- "varSelRF" > > ### * varSelRF > > flush(stderr()); flush(stdout()) > > ### Name: varSelRF > ### Title: Variable selection from random forests using OOB error > ### Aliases: varSelRF > ### Keywords: tree classif > > ### ** Examples > > x <- matrix(rnorm(25 * 30), ncol = 30) > x[1:10, 1:2] <- x[1:10, 1:2] + 2 > cl <- factor(c(rep("A", 10), rep("B", 15))) > > rf.vs1 <- varSelRF(x, cl, ntree = 200, ntreeIterat = 100, + vars.drop.frac = 0.2) > rf.vs1 Backwards elimination on random forest; ntree = 200 ; mtryFactor = 1 Selected variables: [1] "v1" "v2" Number of selected variables: 2 > plot(rf.vs1) Hit to see next plot: Hit to see next plot: > > > cleanEx(); ..nameEx <- "varSelRFBoot" > > ### * varSelRFBoot > > flush(stderr()); flush(stdout()) > > ### Name: varSelRFBoot > ### Title: Bootstrap the variable selection procedure in varSelRF > ### Aliases: varSelRFBoot > ### Keywords: tree classif > > ### ** Examples > > ## Not run: > ##D ## This is a small example, but can take some time. > ##D > ##D x <- matrix(rnorm(25 * 30), ncol = 30) > ##D x[1:10, 1:2] <- x[1:10, 1:2] + 2 > ##D cl <- factor(c(rep("A", 10), rep("B", 15))) > ##D > ##D rf.vs1 <- varSelRF(x, cl, ntree = 200, ntreeIterat = 100, > ##D vars.drop.frac = 0.2) > ##D rf.vsb <- varSelRFBoot(x, cl, > ##D bootnumber = 10, > ##D usingCluster = FALSE, > ##D srf = rf.vs1) > ##D rf.vsb > ##D summary(rf.vsb) > ##D plot(rf.vsb) > ## End(Not run) > > > > > ### *