vec.plot: Compute and plot vector effect characteristics for a given...

Description Usage Arguments Details Value Author(s) Examples

View source: R/vec.plot.R

Description

vec.plot visualizes the vector effect characteristics of a given model. Geometrically it corresponds to a specific 2D or 3D slice of a higher dimensional mapping structure. One variable (2D plot) or two variables (3D plot) are screened within the range of the training data, while remaining variables are fixed at the univariate means (as default). If remaining variables do not interact strongly with plotted variable(s), vec.plot is a good tool to break up a high-dimensional model structure into separate components.

Usage

1
2
vec.plot(model,X,i.var,grid.lines=100,VEC.function=mean,
         zoom=1,limitY=F,moreArgs=list(),...)

Arguments

model

model_object which has a defined method predict.model, which can accept arguments as showed for randomForest e.g. library(randomForest) model = randomForest(X,Y) predict(model,X)

where X is the training features and Y is the training response vector(numeric)

X

matrix or data.frame being the same as input to model

i.var

vector, of column_numbers of variables to scan. No plotting is available for more than two variables.

grid.lines

scalar, number of values by each variable to be predicted by model. Total number of combinations = grid.lines^length(i_var).

VEC.function

function, establish one fixed value for any remaining variables(those not chosen by i.var). Default is to use the mean of variables.

zoom

scalar, number defining the size.factor of the VEC.surface compared to data range of scanned variables. Bigger number is bigger surface.

limitY

boolean, if TRUE Y-axis is standardized for any variable. Useful for composite plots as shown in example.

moreArgs

any lower level graphical args passed to rgl::surface3d or points depending on number of variables(length of i.var)

...

any lower level graphical args passed to rgl::plot3d or plot depending on number of variables(length of i.var)

Details

vec.plot visualizes the vector effect characteristics of a given model. One(2D plot) or two(3D plot) variables are screened within the range of the training data, while remaining variables are fixed at the univariate means of each them(as default). If remaining variables do not interact strongly with plotted variable(s), vec.plot is a good tool to break up a high-dimensional model topology in separate components.

Value

no value

Author(s)

Soren Havelund Welling

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
## Not run: 
## avoid testing of rgl 3D plot on headless non-windows OS
## users can disregard this sentence.
if(!interactive() && Sys.info()["sysname"]!="Windows") skipRGL=TRUE
library(randomForest)
library(forestFloor)

#simulate data
obs=2000
vars = 6 
X = data.frame(replicate(vars,rnorm(obs)))
Y = with(X, X1^2 + 2*sin(X2*pi) + 2 * X3 * (X4+.5))
Yerror = 1 * rnorm(obs)
var(Y)/var(Y+Yerror)
Y= Y+Yerror

#grow a forest, remeber to include inbag
rfo2=randomForest(X,Y,keep.inbag=TRUE,sampsize=800)

#plot partial functions of most important variables first
pars=par(no.readonly=TRUE) #save previous graphical paremeters
par(mfrow=c(2,3),mar=c(2,2,1,1))
for(i in 1:vars) vec.plot(rfo2,X,i,zoom=1.5,limitY=TRUE)
par(pars) #restore

#plot partial functions of most important variables first
for(i in 1:vars) vec.plot(rfo2,X,i,zoom=1.5,limitY=TRUE)

#plotvariable X3 and X4 with vec.plot
Col = fcol(X,3:4)
vec.plot(rfo2,X,3:4,zoom=1,grid.lines=100,col=Col)

## End(Not run)

forestFloor documentation built on May 2, 2019, 2:40 a.m.