partial.plot | R Documentation |
Draw partial relationship graph between focal explanatory variables and response variable with controlling effects of other explanatory variables.
partial.plot(
model,
x.names,
data = NULL,
type = "response",
positive.class = "",
fun.3d = persp,
draw.residual = TRUE,
draw.relationship = TRUE,
draw.interval = TRUE,
draw.hist = FALSE,
interval.levels = 0.95,
resolution = NULL,
col = gg.colors,
lty = "solid",
lwd = 1,
pch = 16,
xlab = NULL,
ylab = NULL,
zlab = NULL,
add = FALSE,
sep = " - ",
extrapolate = FALSE,
n.cores = NULL,
draw = TRUE,
extraporate = extrapolate,
...
)
model |
a model object by which relationship between focal explanatory variables
and response variables is determined. Basically, statistical models and
machine learning models supported by
|
x.names |
a character vector specifying name of focal explanatory variables. Combination of one or two numeric factors and any number of factors is supported. Currently, at least one numeric variable should be specified. This problem may be fixed in future. |
data |
a data.frame used for prediction. If not specified, this function
try to obtain original data used for the modeling from the object
specified by the |
type |
a character literal indicating type of scale of plotting.
This is similar to type argument of many predict methods.
Possible values are "response", "link" and "prob".
If "link" is specified, partial relationship and residuals are
drawn in the scale of the linear predictor.
On the other hand, partial relationship and residuals are drawn
in the scale of the response variable if "response" is specified.
For classification models, only "prob", which calculate probability of
a specific class, can be used. Future version will automatically
change |
positive.class |
a class for which predicted probability is calculated. If not specified, first class of the factor or first unique value of the response variable is used. |
fun.3d |
a function to produce 3d graph. Currently
|
draw.residual |
a logical. If TRUE, points representing partial residual are drawn.
When |
draw.relationship |
a logical. If TRUE, partial relationships between focal explanatory variables and response variable are drawn. |
draw.interval |
a logical. If TRUE, interval of partial relationships are drawn.
Note that currently this intervals are confidential intervals if
|
interval.levels |
values between 0 <= levels <= 1 indicating level(s) of interval. For the models supported by For the models not supported by lsmeans, this can be a value of
lower and upper quantile, e.g., |
resolution |
an integer specifying resolution of lines, polygons, wireframes, and images of numeric variables. Default value is 100 for 2D plots and 10 for 3D plots. Larger number indicate higher resolution. Note that this parameter can affect computation time so that higher resolution require more times to draw the graph. |
col , lty , lwd , pch |
a functions or vectors representing graphic parameters.
For the detail, see pal option of |
xlab , ylab , zlab |
label of X, Y and Z axis. |
add |
add graphic element to existing plot if TRUE. |
sep |
a character used for separator of factor levels. |
extrapolate |
a logical indicating whether extrapolation is allowed for predicted relationships. |
n.cores |
an integer representing number of processes used for calculation. If NULL is specified, maximum number of logical processors are used. This value is ignored when the models compatible with lsmeans are specified. |
draw |
if TRUE, draw partial dependence plot. If FALSE, only calculations of plot parameters were done. |
... |
other graphic parameters passed to plotting functions. Possible parameters for each element of the graph is:
|
For models supported by lsmeans
, this function
calculate partial dependence using lsmeans
and adjusted partial
residual to match result of lsmeans
.
For models having complicated interactions such as machine learning
models, partial dependence is calculated by similar way as
partialPlot
function in randomForest
package.
For the detailed explanation, see vignette("partial.plot")
(English) or vignette("partial.plot.j")
(Japanese)
An object of pp.legend
containing information which
will be used for drawing legend.
#---------------------------------------------------------------------------
# Example 1: normal partial.plot with partial relationship graph with
# points representing partial residuals.
#---------------------------------------------------------------------------
data(iris)
model <- lm(
Petal.Length ~ (Sepal.Length + Petal.Width) * Species, data = iris
)
partial.plot(model, c("Sepal.Length", "Species"), pch = 16)
partial.plot(model, c("Petal.Width", "Species"), pch = 16)
#---------------------------------------------------------------------------
# Example 2: no residuals.
#---------------------------------------------------------------------------
partial.plot(
model, c("Sepal.Length", "Species"), pch = 16, draw.residual = FALSE
)
#---------------------------------------------------------------------------
# Example 3: no partial relationship.
#---------------------------------------------------------------------------
partial.plot(
model, c("Sepal.Length", "Species"), pch = 16,
draw.relationship = FALSE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.