Generate Impulse Response Functions for Covariates
Description
This function will generate an impulse response function (IRF) for a given covariate. The IRF shows the marginal impact of a 1-unit change in the covariate on a person’s ideal point over time. To use this function, the vary_ideal_pts
option in id_estimate
must have received the ‘AR1’
option as IRFs are only available for the AR(1) auto-regressive model.
Usage
id_plot_irf(
object,
cov_name = NULL,
label_high = "Liberal",
label_low = "Conservative",
pred_outcome = NULL,
recalc_vals = F,
include = NULL,
time_calc = 10,
time_label = "Time Points",
line_type = 2,
line_width = 1,
line_alpha = 1,
line_color = "red",
ci_color = "black",
ci_alpha = 0.5,
use_ci = TRUE,
high_quantile = 0.95,
low_quantile = 0.05,
calc_varying = T
)
Arguments
object
|
A fitted idealstan object
|
cov_name
|
The name of the covariate to plot. Leave blank to select from a list of available covariates |
label_high
|
The character label for the upper end of the latent scale |
label_low
|
The character label for the lower end of the latent scale |
pred_outcome
|
For discrete models with more than 2 categories, or binary models with missing data, which outcome to predict. This should be a character value that matches what the outcome was coded as in the data passed to id_make .
|
recalc_vals
|
Whether to combine two variables into one through addition before computing IRFs. If TRUE , two names of parameters should be passed to cov_name or selected from the dialog list
|
include
|
A list of character names of person or group IDs for which to calculate IRFs |
time_calc
|
The maximum number of time points over which to calculate the IRF |
time_label
|
Character string specifying the type of time points (default is just “Time Points” )
|
line_type
|
The line type of the IRF line (see ggplot2 documentation)
|
line_width
|
The line width of the IRF line (see ggplot2 documentation)
|
line_alpha
|
The line alpha (transparency) of the IRF line (see ggplot2 documentation)
|
line_color
|
The color of the IRF line (see ggplot2 documentation)
|
ci_color
|
The color of the IRF credible interval (see ggplot2 documentation)
|
ci_alpha
|
The alpha of the IRF credible interval (see ggplot2 documentation)
|
use_ci
|
Whether or not to plot a credible interval around the lines |
high_quantile
|
The upper limit of the posterior density to use for calculating credible intervals |
low_quantile
|
The lower limit of the posterior density to use for calculating credible intervals |
calc_varying
|
if TRUE , will calculate marginal effects of the covariates on each end of the latent scale (see vignette for more information)
|
Value
a ggplot2
object that can be further customized if necessary