Calculate ideal point marginal effects
Description
This function allows you to calculate ideal point marginal effects for a given person-level hierarchical covariate.
Usage
## S4 method for signature 'idealstan'
id_me(
object,
covariate = NULL,
group_effects = NULL,
pred_outcome = NULL,
eps = 1e-04,
draws = 100,
cores = 1,
lb = 0.05,
upb = 0.95
)
Arguments
object
|
A fitted idealstan model
|
covariate
|
The character value for a covariate passed to the ‘id_make’ function before model fitting. Only one covariate can be processed at a time. |
group_effects
|
character value of a covariate included in the formula passed to ‘id_make’ for which marginal effect summaries should be grouped by. Useful when looking at the marginal effect of an interaction. Note that grouping by a covariate with many values will result in slow performance. |
pred_outcome
|
Numeric value for level of outcome to predict for ordinal responses. Defaults to top level. |
eps
|
The value used for numerical differentiation. Default is 1e-4. Usually does not need to be changed. |
draws
|
The total number of draws to use when calculating the marginal effects. Defaults to 100. Use option "all" to use all available MCMC draws. |
cores
|
The total number of cores to use when calculating the marginal effects. Defaults to 1. |
lb
|
The quantile for the lower bound of the aggregated effects (default is 0.05) |
upb
|
The quantile for the upper bound of the aggregated effects (default is 0.95) |
Details
This function will calculate item-level ideal point marginal effects for a given covariate that was passed to the ‘id_make’ function using the ‘person_cov’ option. The function will iterate over all items in the model and use numerical differentiation to calculate responses in the scale of the outcome for each item. Note: if the covariate is binary (i.e., only has two values), then the function will calculate the difference between these two values instead of using numerical differentation.
Value
A list with two objects, ideal_effects
with one estimate of the marginal effect per item and posterior draw and sum_ideal_effects
with one row per item with that item’s median ideal point marginal effect with the quantiles defined by the upb
and lb
parameters.