View source: R/make_predictions.R
make_predictions | R Documentation |
This is an alternate interface to the underlying tools that
make up effect_plot()
as well as interactions::interact_plot()
and
interactions::cat_plot()
from the interactions
package.
make_predictions()
creates the data to be plotted and adds information
to the original data to make it more amenable for plotting with the
predicted data.
make_predictions(model, ...)
## Default S3 method:
make_predictions(
model,
pred,
pred.values = NULL,
at = NULL,
data = NULL,
center = TRUE,
interval = TRUE,
int.type = c("confidence", "prediction"),
int.width = 0.95,
outcome.scale = "response",
robust = FALSE,
cluster = NULL,
vcov = NULL,
set.offset = NULL,
new_data = NULL,
return.orig.data = FALSE,
partial.residuals = FALSE,
...
)
model |
The model (e.g., |
... |
Ignored. |
pred |
The name of the focal predictor as a string. This is the variable for which, if you are plotting, you'd likely have along the x-axis (with the dependent variable as the y-axis). |
pred.values |
The values of |
at |
If you want to manually set the values of other variables in the model, do so by providing a named list where the names are the variables and the list values are vectors of the values. This can be useful especially when you are exploring interactions or other conditional predictions. |
data |
Optional, default is NULL. You may provide the data used to
fit the model. This can be a better way to get mean values for centering
and can be crucial for models with variable transformations in the formula
(e.g., |
center |
Set numeric covariates to their mean? Default is TRUE. You
may also just provide a vector of names (as strings) of covariates to
center. Note that for |
interval |
Logical. If |
int.type |
Type of interval to plot. Options are "confidence" or "prediction". Default is confidence interval. |
int.width |
How large should the interval be, relative to the standard error? The default, .95, corresponds to roughly 1.96 standard errors and a .05 alpha level for values outside the range. In other words, for a confidence interval, .95 is analogous to a 95% confidence interval. |
outcome.scale |
For nonlinear models (i.e., GLMs), should the outcome
variable be plotted on the link scale (e.g., log odds for logit models) or
the original scale (e.g., predicted probabilities for logit models)? The
default is |
robust |
Should robust standard errors be used to find confidence
intervals for supported models? Default is FALSE, but you should specify
the type of sandwich standard errors if you'd like to use them (i.e.,
|
cluster |
For clustered standard errors, provide the column name of the cluster variable in the input data frame (as a string). Alternately, provide a vector of clusters. |
vcov |
Optional. You may supply the variance-covariance matrix of the coefficients yourself. This is useful if you are using some method for robust standard error calculation not supported by the sandwich package. |
set.offset |
For models with an offset (e.g., Poisson models), sets an offset for the predicted values. All predicted values will have the same offset. By default, this is set to 1, which makes the predicted values a proportion. See details for more about offset support. |
new_data |
If you would prefer to generate your own hypothetical
(or not hypothetical) data rather than have the function make a call to
|
return.orig.data |
Instead of returning a just the predicted data frame, should the original data be returned as well? If so, then a list will be return with both the predicted data (as the first element) and the original data (as the second element). Default is FALSE. |
partial.residuals |
If |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.