R: Plot predicted values from a model against one of the...
TkPredict
R Documentation
Plot predicted values from a model against one of the predictors
for a given value of the othe predictors
Description
These functions create a plot of predicted values vs. one of the
predictors for given values of the other predictors. TkPredict
further creates a Tk gui to allow you to change the values of the
other predictors.
A model of class 'lm' or 'glm' (or possibly others) from
which to plot predictions.
pred.var
A character string indicating which predictor variable
to put on the x-axis of the plot.
...
for Predict.Plot The predictor variables and their
values for the predictions. See below for detail.
type
The type value passed on to the predict function.
add
Whether to add a line to the existing plot or start a new
plot.
plot.args
A list of additional options passed on to the
plotting function.
n.points
The number of points to use in the approximation of
the curve.
ref.val
A reference value for the pred.var, a reference
line will be drawn at this value to the corresponding predicted value.
ref.col, ref.lty
The color and line type of the reference line
if plotted.
data
The data frame or environment where the variables that the
model was fit to are found. If missing, the model will be examined
for an attempt find the needed data.
Details
These functions plot the predicted values from a regression model
(lm or glm) against one of the predictor variables for
given values of the other predictors. The values of the other
predictors are passed as the ... argument to
Predict.Plot or are set using gui controls in TkPredict
(initial values are the medians).
If the variable for the x axis (name put in pred.var) is not
included with the ... variables, then the range will be
computed from the data argument or the data component of the
model argument.
If the variable passed as pred.var is also included in the
... arguments and contains a single value, then this value will
be used as the ref.val argument.
If it contains 2 or more values, then the range of these values will
be used as the x-limits for the predictions.
When running TkPredict you can click on the "Print Call" button
to print out the call of Predict.Plot that will recreate the
same plot. Doing this for different combinations of predictor values
and editing the plot.args and add arguments will give
you a script that will create a static version of the predictions.
Value
These functions are run for their side effects of creating plots and
do not return anything.
Note
The GUI currently allows you to select a factor as the
x-variable. If you do this it will generate some errors and you will
not see the plot, just choose a different variable as the x-variable
and the plot will return.