Learn R Programming

condvis (version 0.2-2)

plotxs: Expectation plot

Description

Plot depicting a section through a fitted model surface (or a conditional expectation). Not designed to be called by the user.

Usage

plotxs(xs, y, xc.cond, model, model.colour = NULL, model.lwd = NULL,
       model.lty = NULL, model.name = NULL, yhat = NULL, mar = NULL, 
       data.colour = NULL, data.order = NULL, view3d = FALSE, theta3d = 45,
       phi3d = 20)

Arguments

xs
a data.frame with one or two columns.
y
a data.frame with one column.
xc.cond
a data.frame with one row.
model
a model object, or a list of model objects.
model.colour, model.lwd, model.lty
graphical parameters passed to col, lwd and lty respectively in a call to points (to differentiate between models).
model.name
names for the models in model, used for the legend.
yhat
a list of fitted values for the models in model
mar
margins for plotting.
data.colour
vector of colours for plotting the raw data (xs and/or y)
data.order
integer vector giving the order in which to plot raw data
view3d
logical; if TRUE, a 3-d perspective plot is produced if possible
theta3d
horizontal rotation of perspective plot
phi3d
vertical rotation of perspective plot

Value

  • A list containing:
  • xs
  • y
  • xc.cond
  • model
  • model.colour
  • model.lwd
  • model.lty
  • model.name
  • yhat
  • mar
  • data.colour
  • data.order
  • view3d
  • theta3d
  • phi3d

See Also

ceplot, plotxc.

Examples

Run this code
## expected value of 'mpg' conditional on fitted model and predictor values in 
## first observation of mtcars, evaluated for a range of 'wt' values.

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