id_plot_cov: Marginal Effects Plot for Hierarchical Covariates

Description Usage Arguments Details Value

View source: R/Plot.R

Description

This function will calculate marginal effects, or the first derivative of the IRT/ideal point model with respect to the hierarchical covariate, separately for the two poles of the latent variable. These two marginal effects permit the interpretation of the effect of the covariate on with respect to either end of the latent variable.

Usage

1
2
3
4
id_plot_cov(object, calc_varying = T, label_high = "Liberal",
  label_low = "Conservative", cov_type = "person_cov",
  pred_outcome = NULL, high_quantile = 0.95, low_quantile = 0.05,
  filter_cov = NULL, new_cov_names = NULL, recalc_vals = NULL)

Arguments

object

A fitted idealstan object

calc_varying

Whether to marginalize covariate effects over discrimination parameters to calculate a meaningful quantity for the effect of covariates on the latent scale (see vignette). Defaults to TRUE

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

cov_type

Either 'person_cov' for person or group-level hierarchical parameters, 'discrim_reg_cov' for bill/item discrimination parameters from regular (non-inflated) model, and 'discrim_infl_cov' for bill/item discrimination parameters from inflated model.

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.

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

filter_cov

A character vector of coefficients from covariate plots to exclude from plotting (should be the names of coefficients as they appear in the plots)

new_cov_names

A character vector of length equal to the number of covariates (plus 1 for the intercept) to change the default labels. To see the default labels, use the plot function with this option blank. The character vector should be of th form used by

recalc_vals

A character value of length three that can be used to create a new variable that is a sum of two other variables. The first two values of the character vector are the names of these parameters, while the third value is the name of the new combined variable. Note that if the parameters are renamed, the new names should be used in this option.

Details

Because the marginal effects are always with respect to a given outcome/response, the outcome to be predicted must be specified in pred_outcome. If it is not specified, the function will prompt you to select one of the outcome's values in the data.

The ends of the latent variable can be specified via the label_low and label_high options, which will use those labels in the ensuing plot.

To exclude parameters from the plot, use the filter_cov option. Note that the parameters must be specified using the underlying model syntax (however they are labeled in the plot). You can also change the names of parameters using the new_cov_names option.

Note that the function produces a ggplot2 object, which can be further modified with ggplot2 functions.

Value

A ggplot2 plot that can be further customized with ggplot2 functions if need be.


idealstan documentation built on July 10, 2019, 5:05 p.m.