The section plot relates a fit or fits to one or two predictors (sectionvar
),
for fixed values of other predictors in conditionvals
.
sectionPlot(
CVdata,
CVfit = NULL,
response = NULL,
preds,
sectionvar,
conditionvals,
pointColor = "steelblue",
sim = NULL,
threshold = 1,
linecols = NULL,
dataplot = "pcp",
gridsize = 50,
probs = FALSE,
view3d = FALSE,
theta3d = 45,
phi3d = 20,
xlim = NULL,
ylim = NULL,
zlim = NULL,
pointSize = 1.5,
predictArgs = NULL,
resetpar = TRUE,
density = FALSE,
showdata = density == FALSE,
returnInfo = FALSE,
pointColorFromResponse = FALSE,
pcolInfo = NULL
)
the dataset used for the fit
a fit or list of fits
name of response variable
names of predictors
section variable, or variables.
conditioning values. A vector/list or dataframe with one row
a color, vector of colors,or the name of variable to be used for coloring
vector of similarity weights
used for similarity weights, defaults to 1.
vector of line colours
"pcp" or "pairs". Used when there is no response, or more than two sectionvars.
used to construct grid of fitted values.
Logical; if TRUE
, shows predicted class probabilities instead of just predicted classes. Only available with two numeric sectionvars and the model's predict method provides this.
Logical; if TRUE
plots a three-dimensional regression surface if possible.
Angles defining the viewing direction. theta3d
gives the azimuthal direction and phi3d
the colatitude. Seepersp
.
passed on to plot
passed on to plot
passed on to plot
used for points
a list with one entry per fit, giving arguments for predict
When TRUE (the default) resets pars after drawing.
default FALSE. Use TRUE if model is a density function.
If FALSE, data on section not shown.
If TRUE, returns coordinates for some plots
ignore--For interactive use only
ignore--For interactive use only
plotted coordinates, for some plots
The type of plot depends on the fit and the section variables. Observations with non zero values of the similarity weights
sim
are shown. If no fit is provided, the data are shown as a parallel coordinate plot or pairs
plot, depending on dataplot
.
The fit could also be a density estimate.
#Fit a model.
f <- lm(Fertility~ ., data=swiss)
svar <- "Education"
preds <- variable.names(f)[-1]
sectionPlot(swiss,f, "Fertility",preds,svar, swiss[12,])
sectionPlot(swiss,f, "Fertility",preds,svar, apply(swiss,2,median))
sectionPlot(swiss,f, "Fertility",preds,preds[1:2], apply(swiss,2,median))
sectionPlot(swiss,f, "Fertility",preds,preds[1:2], apply(swiss,2,median), view3d=TRUE)
# PCP of swiss data, showing only cases whose percent catholic and infant.mortality are
# similar to those of the first case
sectionPlot(swiss,preds=names(swiss),
sectionvar= names(swiss)[1:4],conditionvals=swiss[1,] )
# Use dataplot="pairs" to switch to a pairs plot
# A density estimate example
if (FALSE) {
library(ks)
fde <-kde(iris[,1:3])
sectionPlot(iris,list(kde=fde), response=NULL,
preds=names(iris)[1:3],
sectionvar=names(iris)[1],
conditionvals=iris[1,],density=TRUE)
}