Visualise a section in data space, showing fitted models where
they intersect the section, and nearby observations. The weights for
observations can be calculated with similarityweight. This
function is mainly for use in ceplot and
condtour.
plotxs(xs, y, xc.cond, model, model.colour = NULL, model.lwd = NULL,
model.lty = NULL, model.name = NULL, yhat = NULL, mar = NULL,
col = "black", weights = NULL, view3d = FALSE, theta3d = 45,
phi3d = 20, xs.grid = NULL, prednew = NULL, conf = FALSE,
probs = FALSE, pch = 1, residuals = FALSE, main = NULL, xlim = NULL,
ylim = NULL)A dataframe with one or two columns.
A dataframe with one column.
A dataframe with a single row, with all columns required for
passing to predict methods of models in model.
A fitted model object, or a list of such objects.
Colours for fitted models. If model is a list,
this should be of same length as model.
Line weight for fitted models. If model is a list,
this should be of same length as model.
Line style for fitted models. If model is a list,
this should be of same length as model.
Character labels for models, for legend.
Fitted values for the observations in y. Calculated if
needed and not provided. Only used if showing residuals, or xs has
two columns.
Margins for plot.
Colours for observed data. Should be of length nrow(xs).
Similarity weights for observed data. Should be of length
nrow(xs). Usually calculated with similarityweight.
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. See
persp.
The grid of values defining the part of the section to visualise. Calculated if not provided.
The y values where the models in model intersect
the section. Useful when providing theta3d, phi3d, or
weights, where the predict methods have been called elsewhere.
Logical; if TRUE plots confidence bounds (or equivalent)
for models which provide this.
Logical; if TRUE, shows predicted class probabilities
instead of just predicted classes. Only available if xs contains two
numeric predictors and the model's predict method provides this.
Plot symbols for observed data
Logical; if TRUE, plots a residual versus predictor
plot instead of the usual scale of raw response.
Character title for plot, default is
"Conditional expectation".
Graphical parameter passed to plotting functions.
Graphical parameter passed to plotting functions.
A list containing relevant information for updating the plot.
O'Connell M, Hurley CB and Domijan K (2017). ``Conditional Visualization for Statistical Models: An Introduction to the condvis Package in R.''Journal of Statistical Software, 81(5), pp. 1-20. <URL:http://dx.doi.org/10.18637/jss.v081.i05>.
# NOT RUN {
data(mtcars)
model <- lm(mpg ~ ., data = mtcars)
plotxs(xs = mtcars[, "wt", drop = FALSE], y = mtcars[, "mpg", drop = FALSE],
xc.cond = mtcars[1, ], model = list(model))
# }
Run the code above in your browser using DataLab