# List the Stan models included in edstan
folder <- system.file("extdata", package = "edstan")
dir(folder, "\\.stan$")
# List the contents of one of the .stan files
rasch_file <- system.file("extdata/rasch_latent_reg.stan",
package = "edstan")
cat(readLines(rasch_file), sep = "\n")
if (FALSE) {
# 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 = ~ 1 + male)
rasch_fit <- irt_stan(spelling_list, iter = 300, chains = 4)
print_irt_stan(rasch_fit, spelling_list)
twopl_fit <- irt_stan(spelling_list, model = "2pl_latent_reg.stan",
iter = 300, 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 = labelled_integer(aggression$description),
jj = aggression$person)
fit_rsm <- irt_stan(agg_list_1, model = "rsm_latent_reg.stan",
iter = 300, chains = 4)
print_irt_stan(fit_rsm, agg_list_1)
fit_pcm <- irt_stan(agg_list_1, model = "pcm_latent_reg.stan",
iter = 300, 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 = labelled_integer(aggression$description),
jj = aggression$person,
covariates = aggression[, c("male", "anger")],
formula = ~ 1 + male*anger)
fit_grsm <- irt_stan(agg_list_2, model = "grsm_latent_reg.stan",
iter = 300, chains = 4)
print_irt_stan(fit_grsm, agg_list_2)
fit_gpcm <- irt_stan(agg_list_2, model = "gpcm_latent_reg.stan",
iter = 300, chains = 4)
print_irt_stan(fit_grsm, agg_list_2)
}
Run the code above in your browser using DataLab