| id_me,idealstan-method | R Documentation |
This function allows you to calculate ideal point marginal effects for a given person-level hierarchical covariate.
## 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.025,
upb = 0.975,
...
)
object |
A fitted |
covariate |
The character value for a covariate passed to the
|
group_effects |
character value of a covariate included in the formula passed
to |
pred_outcome |
Numeric value for level of outcome to predict for ordinal responses. Defaults to top level. |
eps |
Parameter for numerical differentiation (usually does not need to be changed) passed on to id_post_pred |
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.025 for a 95% interval) |
upb |
The quantile for the upper bound of the aggregated effects (default is 0.975 for a 95% interval) |
... |
Additional arguments passed on to id_post_pred |
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.
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.
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", ncores=4)
me <- id_me(sen_cov_est, covariate='age', draws=50)
me$sum_ideal_effects
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.