-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Hello Robert Kubinec,
I'm using your package to run a dynamic ordinal ideal point model. Note that I'm using the development version of your package. I have two issues to discuss with you:
- While trying to access the item discrimination + difficulty parameters with the summary function, I get the error
Can't find the following variable(s) in the output: steps_votes. - Why is there only one difficulty parameter per item when graded response models should have multiple difficulty parameters for each item (usually equal to the number of response categories - 1)?
I'll first provide some background on my data and the idealstan code I'm using. Then I'll provide more details on the two aforementioned issues.
My data consists of ordinal likert-type items over four time periods (2011, 2015, 2019, and 2022). Items from the 2011 & 2015 periods have 5 response categories, while items from the 2019 & 2022 periods have 4 response categories. For all items, I'm using model_type = 5, the ordinal IRT (graded response) ideal point model with no missing-data inflation.
Here's my code:
idealstan_object <- id_make(
score_data = Nat_DAN_IRT_Data_long_GALTAN,
person_id = "person_id",
item_id = "VAA_item_questions",
time_id = "year",
group_id = "party_abbr",
model_id = "idealstan_model",
unbounded = FALSE,
outcome_disc = "VAA_item_answers",
ordered_id = "n_responses"
)
DAN_GALTAN_idealstan_output_PREFIX <- id_estimate(
idealdata = idealstan_object,
model_type = 5,
vary_ideal_pts = "random_walk",
fixtype = "prefix",
const_type = "items",
restrict_ind_high = "Alt2022_Q3",
restrict_ind_low = "Alt2019_Q26",
ncores = parallel::detectCores(),
grainsize = 1,
nchains = 4,
id_refresh = 10,
time_var = 0.5,
restrict_var = F
)
I'll now provide more information about the aforementioned issues.
Issue 1: Unaccessible Item Parameters.
This is the code I use to access the item parameters:
summary(DAN_GALTAN_idealstan_output_PREFIX, pars = "items")
That code produces the following error: Error: Can't find the following variable(s) in the output: steps_votes
After looking through the code myself, I found that this line of code in the .item_plot_ord_grm function in the Helpers.R file is causing the error:
total_cat <- length(as_draws_df(object@stan_samples$draws('steps_votes')))
I tried to fix the issue myself by modifying that code line and an additional line with the following:
# figure out how many categories we need
## I still don't really know what this is doing. I'm currently interpeting it as the number of unique response categories in the dataframe. I changed it so that it obtains this number from the score_matrix
total_cat <- unique(object@score_data@score_matrix[object@score_data@score_matrix$item_id == param_name,]$ordered_id)
# Obtain the cuts. I modified this significantly despite not being sure if this is how it works. Notice that it subtracts 1 from total_cat. This is because it includes the 'missing' category
cuts <- as_draws_df(object@stan_samples$draws(paste0('steps_votes_grm', total_cat, '[', param_num, ',', 1:(total_cat - 1), ']')))
Did I identify the cause of the error? And do you think that my modifications adequately fixed the problem?
Issue 2: Too-Few Difficulty Parameters
Secondly, it seems like the command summary(DAN_GALTAN_idealstan_output_PREFIX, pars = "items") only produces estimates for one difficulty parameter per item. Yet graded response models have multiple difficulty parameters for each ordered response category in an item. Do you know why this is happening? How can I obtain the multiple unique difficulty parameters?