irt_stan function

Fit an item response model with Stan

Fit an item response model with Stan

This function initiates sampling for an edstan model.

irt_stan(data_list, model = "", ...)

Arguments

  • data_list: A Stan data list created with irt_data.
  • model: The file name for one of the provided .stan files, or alternatively, a user-created .stan file that accepts data_list as input data. The ".stan" file extension may be omitted. Defaults to either "rasch_latent_reg.stan" or "pcm_latent_reg.stan".
  • ...: Additional options passed to stan. The usual choices are iter for the number of iterations and chains for the number of chains.

Returns

A stanfit-class object.

Details

The following table lists the models included in edstan along with the associated .stan files. These file names are given as the model

argument.

ModelFile
Raschrasch_latent_reg.stan
Partial creditpcm_latent_reg.stan
Rating Scalersm_latent_reg.stan
Two-parameter logistic2pl_latent_reg.stan
Generalized partial creditgpcm_latent_reg.stan
Generalized rating Scalegrsm_latent_reg.stan

Three simplified models are also available: rasch_simple.stan, pcm_simple.stan, rsm_simple.stan. These are (respectively) the Rasch, partial credit, and rating scale models omitting the latent regression. There is no reason to use these instead of the models listed above, given that the above models allow for rather than require the inclusion of covariates for a latent regression. Instead, the purpose of the simplified models is to provide a straightforward starting point researchers who wish to craft their own Stan models.

Examples

## Not run: # Fit the Rasch and 2PL models on wide-form data with a latent regression spelling_list <- irt_data(response_matrix = spelling[, 2:5], covariates = spelling[, "male", drop = FALSE], formula = ~ rescale_binary(male)) rasch_fit <- irt_stan(spelling_list, iter = 2000, chains = 4) print_irt_stan(rasch_fit, spelling_list) twopl_fit <- irt_stan(spelling_list, model = "2pl_latent_reg.stan", iter = 2000, chains = 4) print_irt_stan(twopl_fit, spelling_list) # Fit the rating scale and partial credit models without a latent regression agg_list_1 <- irt_data(y = aggression$poly, ii = aggression$description, jj = aggression$person) fit_rsm <- irt_stan(agg_list_1, model = "rsm_latent_reg.stan", iter = 2000, chains = 4) print_irt_stan(fit_rsm, agg_list_1) fit_pcm <- irt_stan(agg_list_1, model = "pcm_latent_reg.stan", iter = 2000, chains = 4) print_irt_stan(fit_pcm, agg_list_1) # Fit the generalized rating scale and partial credit models including # a latent regression agg_list_2 <- irt_data(y = aggression$poly, ii = aggression$description, jj = aggression$person, covariates = aggression[, c("male", "anger")], formula = ~ rescale_binary(male)*rescale_continuous(anger)) fit_grsm <- irt_stan(agg_list_2, model = "grsm_latent_reg.stan", iter = 2000, chains = 4) print_irt_stan(fit_grsm, agg_list_2) fit_gpcm <- irt_stan(agg_list_2, model = "gpcm_latent_reg.stan", iter = 2000, chains = 4) print_irt_stan(fit_grsm, agg_list_2) ## End(Not run)

See Also

See stan, for which this function is a wrapper. See irt_data for creating the data list. See rescale_continuous and rescale_binary for appropriately scaling latent regression covariates. See print_irt_stan and print.stanfit for ways of getting tables summarizing parameter posteriors.

  • Maintainer: Daniel C. Furr
  • License: BSD_3_clause + file LICENSE
  • Last published: 2025-03-24

Useful links