| id_plot_cov | R Documentation |
This function will calculate and plot the ideal point marginal effects, or the first derivative
of the IRT/ideal point model with respect to the hierarchical covariate,
for each item in the model. The function id_me() is used
to first calculate the ideal point marginal effects.
id_plot_cov(
object,
calc_param = NULL,
label_high = "High",
label_low = "Low",
group_effects = NULL,
plot_model_id = NULL,
pred_outcome = NULL,
lb = 0.05,
upb = 0.95,
facet_ncol = 2,
cov_type = "person_cov",
...
)
object |
A fitted |
calc_param |
Whether to calculate ideal point marginal effects for
a given covariate. If NULL, the default, the function will instead produce
a plot of the raw coefficients from the ideal point model. If passing the
name of a covariate, should be a character value of a column in the data
passed to the
|
label_high |
What label to use on the plot for the high end of the latent scale |
label_low |
What label to use on the plot for the low end of the latent scale |
group_effects |
Character value for name of column in data by which to subset the data. Must be a column passed to the id_make function |
plot_model_id |
The integer of the model ID to plot. If NULL and there
are multiple model types, |
pred_outcome |
For discrete models with more than 2 categories,
or binary models with missing data, which outcome to predict. This should
be the value that matches what the outcome was coded as in the data
passed to |
lb |
The lower limit of the posterior density to use for calculating credible intervals |
upb |
The upper limit of the posterior density to use for calculating credible intervals |
facet_ncol |
If facetting by multiple models or grouped factors, sets the number of columns in the multiple plots |
cov_type |
Either |
... |
Additional argument passed on to |
The ends of the latent variable can be specified via the
label_low and label_high options, which will use those
labels for item discrimination.
Note that the function produces a ggplot2 object, which can
be further modified with ggplot2 functions.
A ggplot2 plot that can be further customized with ggplot2 functions if need be.
# Fit a model with a person-level covariate
data('senate114')
senate114$cast_code <- ifelse(senate114$cast_code=="Absent", NA,
as.integer(senate114$cast_code) - 1L)
senate114$age <- (2018 - senate114$born - mean(2018 - senate114$born)) / 10
sen_cov <- id_make(senate114, outcome_disc='cast_code',
person_id='bioname', item_id='rollnumber',
group_id='party_code', person_cov=~party_code+age)
sen_cov_est <- id_estimate(sen_cov, model_type=1, fixtype='vb_full',
use_method="pathfinder", nchains=2, ncores=4)
# Plot marginal effects of age on ideal points
id_plot_cov(sen_cov_est, calc_param='age')
# Plot the raw person-level covariate coefficients
id_plot_cov(sen_cov_est)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.