Description Usage Arguments Details Value See Also Examples
View source: R/fitting_functions.R
Estimate an item response model with Stan
1 |
data_list |
A Stan data list created with |
model |
The file name for one of the provided .stan files, or
alternatively, a user-created .stan file that accepts |
... |
Additional options passed to |
The following table lists the models inlcuded in edstan along with the
associated .stan files. The file names are given as the model
argument.
Model | File |
Rasch | rasch_latent_reg.stan |
Partial credit | pcm_latent_reg.stan |
Rating Scale | rsm_latent_reg.stan |
Two-parameter logistic | 2pl_latent_reg.stan |
Generalized partial credit | gpcm_latent_reg.stan |
Generalized rating Scale | grsm_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.
A stanfit-class
object.
See stan
, for which this function is a wrapper,
for additional options.
See irt_data
and labelled_integer
for functions
that facilitate creating a suitable data_list
.
See print_irt_stan
and print.stanfit
for ways of
getting tables summarizing parameter posteriors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | # 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")
## 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 = ~ 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)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.