jtools (version 1.1.1)

make_predictions.rq: Make predictions for quantile regression models

Description

This method adds support for plot_predictions, interact_plot, cat_plot, and effect_plot for models fit with rq.

Usage

# S3 method for rq
make_predictions(model, pred, pred.values = NULL,
  modx = NULL, modx.values = NULL, mod2 = NULL, mod2.values = NULL,
  centered = "all", data = NULL, plot.points = FALSE,
  int.width = 0.95, outcome.scale = "response",
  linearity.check = FALSE, set.offset = 1, pred.labels = NULL,
  modx.labels = NULL, mod2.labels = NULL, int.type = c("confidence",
  "prediction"), preds.per.level = 100, force.cat = FALSE,
  se = c("nid", "iid", "ker"), facet.modx = linearity.check, ...)

Arguments

model

A rq model.

pred

The name of the predictor variable involved in the interaction. This must be a string.

pred.values

Which values of the predictor should be included in the plot? By default, all levels are included.

modx

The name of the moderator variable involved in the interaction. This must be a string.

modx.values

For which values of the moderator should lines be plotted? Default is NULL. If NULL, then the customary +/- 1 standard deviation from the mean as well as the mean itself are used for continuous moderators. If "plus-minus", plots lines when the moderator is at +/- 1 standard deviation without the mean. You may also choose "terciles" to split the data into equally-sized groups and choose the point at the mean of each of those groups.

If the moderator is a factor variable and modx.values is NULL, each level of the factor is included. You may specify any subset of the factor levels (e.g., c("Level 1", "Level 3")) as long as there is more than 1. The levels will be plotted in the order you provide them, so this can be used to reorder levels as well.

mod2

Optional. The name of the second moderator variable involved in the interaction. This can be a bare name or string.

mod2.values

For which values of the second moderator should the plot be facetted by? That is, there will be a separate plot for each level of this moderator. Defaults are the same as modx.values.

centered

A vector of quoted variable names that are to be mean-centered. If "all", all non-focal predictors are centered. You may instead pass a character vector of variables to center. User can also use "none" to base all predictions on variables set at 0. The response variable, pred, modx, and mod2 variables are never centered.

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., log(x)) or polynomial terms (e.g., poly(x, 2)). You will see a warning if the function detects problems that would likely be solved by providing the data with this argument and the function will attempt to retrieve the original data from the global environment.

plot.points

Logical. If TRUE, plots the actual data points as a scatterplot on top of the interaction lines. The color of the dots will be based on their moderator value.

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 "response", which is the original scale. For the link scale, which will show straight lines rather than curves, use "link".

linearity.check

For two-way interactions only. If TRUE, plots a pane for each level of the moderator and superimposes a loess smoothed line (in gray) over the plot. This enables you to see if the effect is linear through the span of the moderator. See Hainmueller et al. (2016) in the references for more details on the intuition behind this. It is recommended that you also set plot.points = TRUE and use modx.values = "terciles" with this option.

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.

pred.labels

A character vector of 2 labels for the predictor if it is a 2-level factor or a continuous variable with only 2 values. If NULL, the default, the factor labels are used.

modx.labels

A character vector of labels for each level of the moderator values, provided in the same order as the modx.values argument. If NULL, the values themselves are used as labels unless modx,values is also NULL. In that case, "+1 SD" and "-1 SD" are used.

mod2.labels

A character vector of labels for each level of the 2nd moderator values, provided in the same order as the mod2.values argument. If NULL, the values themselves are used as labels unless mod2.values is also NULL. In that case, "+1 SD" and "-1 SD" are used.

int.type

Type of interval to plot. Options are "confidence" or "prediction". Default is confidence interval.

preds.per.level

For continuous predictors, a series of equally spaced points across the observed range of the predictor are used to create the lines for each level of the moderator. Use this to choose how many points are used for that. Default is 100, but for complicated models larger numbers may better capture the curvature.

force.cat

If TRUE, treats numeric predictor as categorical. This can be helpful when you have 0/1 dummy variables that you don't want to plot as if intermediate values are possible.

se

One of "nid", "iid", "ker", standard error options defined by summary.rq.

facet.modx

Create separate panels for each level of the moderator? Default is FALSE, except when linearity.check is TRUE.

...

Ignored.