permtestImp: Testing Importance of All Variables

Description Usage Arguments Value Examples

View source: R/MSE_Test_File.R

Description

This method runs the variable importance procedure (MSE_Test) on each variable in the data frame, marginally, with an available plot method.

Usage

1
2
3
4
permtestImp(X, y, X.test = FALSE, y.test = FALSE,
  single_forest = T, NTest = nrow(X.test), Nbtree = 30,
  verbose = F, keep_forest = F, base.learner = "rpart",
  mtry = ncol(X), p = 0.5, ...)

Arguments

X

Data frame of covariates - the training data.

y

Response vector. Currently only numeric responses (regression) are supported.

X.test

Covariates of the test set with which the MSE is calculated.

y.test

Responses in the test set with which the MSE is calculated.

base.learner

One of "rpart", "ctree", "rtree", or "lm". Base model to be used in the bagging.

single_forest

Logical. If TRUE, then all variables are compared against a single original forest.

NTest

If X.test, y.test are not specified, this number of test points are drawn at random from X, y.

Nbtree

How many trees should be used for each variable. Can either be a single number, or a vector of length ncol(X), with each entry corresponding to the number of trees used for testing each column.

verbose

Logical. Should a progress tracker be output in the console?

keep_forest

Logical. Should the original random forest be returned?

mtry

The mtry parameter used in random forest models.

p

Subsample size exponent, see MSE_Test.

...

Additional arguments to be passed to MSE_Test.

Value

Returns an object of S4 class permtestImp with the following values

ImportanceTable

A data.frame tabulating each variable and its importance.

call

The original call, as provided by match.call()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
set.seed(367116)
N <- 1250
Nvar <- 5
name_vec <- paste("X", 1:(2*Nvar), sep = "")

# training data:
X <- data.frame(replicate(Nvar, runif(N)),
                replicate(Nvar, cut(runif(N), 3,
                                      labels = as.character(1:3))))
names(X) <- name_vec

## Example where response is unrelated to any features
pm.null <- permtestImp(X = X, y = rnorm(N),
                         single_forest = F, base.learner = "rtree",
                        mtry = 3, NTest = 100, Nbtree = 100, B = 1000,
                       p = .75, verbose = T)

## Plotting the Importance Output
plot(pm.null)

tim-coleman/RFtest documentation built on March 10, 2020, 12:28 p.m.