View source: R/marginal_moments.R
| marginal_moments | R Documentation |
Given an estimated model and a prior density function, compute the marginal moments for either and item or a bundle of items. Function returns the first found moments implied by the model and select density function (MEAN, VAR, SKEW, and KURT). Currently limited to unidimensional IRT models.
marginal_moments(
mod,
which.items = NULL,
group = NULL,
bundle = TRUE,
density = NULL,
Theta_lim = c(-6, 6),
quadpts = 121,
...
)
mod |
an object of class |
which.items |
vector indicating which items to use in the computation of the expected values.
Default ( |
group |
optional indicator to return only specific group information for multiple group models.
Default compute moments for each group, returning a |
bundle |
logical; given |
density |
a density function to use for integration. Default assumes the latent traits are from a
normal (Gaussian) distribution. Function definition must be of the form |
Theta_lim |
range of integration grid to use when forming expectations |
quadpts |
number of discrete quadrature to use in the computations |
... |
additional arguments passed to the density function |
Phil Chalmers rphilip.chalmers@gmail.com
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Environment. Journal of Statistical Software, 48(6), 1-29. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v048.i06")}
expected.item, expected.test
# single group
dat <- expand.table(deAyala)
mod <- mirt(dat)
TS <- rowSums(dat)
# expected moments of total scores given model
marginal_moments(mod)
c(mean=mean(TS), var=var(TS)) # first two moments of data
# same, however focusing on individual items
marginal_moments(mod, bundle = FALSE)
cbind(mean=colMeans(dat), var=apply(dat, 2, var)) # first two moments of data
############################################
## same as above, however with multiple group model
set.seed(1234)
group <- sample(c('G1', 'G2'), nrow(dat), replace=TRUE)
modMG <- multipleGroup(dat, group=group,
invariance=c(colnames(dat), 'free_mean', 'free_var'))
coef(modMG, simplify=TRUE)
# expected moments of total scores given model
marginal_moments(modMG)
marginal_moments(modMG, group = 'G1') # specific group only
# same, however focusing on individual items
marginal_moments(modMG, bundle = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.