Learn R Programming

mirt (version 0.6.0)

multipleGroup: Multiple Group Estimation

Description

multipleGroup performes a full-information maximum-likelihood multiple group analysis for dichotomous and polytomous data under the item response theory paradigm using either Cai's (2010) Metropolis-Hastings Robbins-Monro algorithm or with an EM approach.

Usage

multipleGroup(data, model, group, itemtype = NULL, guess
    = 0, upper = 1, SE = FALSE, SE.type = 'MHRM', SEtol =
    .001, invariance = '', pars = NULL, method = 'EM',
    constrain = NULL, parprior = NULL, calcNull = TRUE,
    draws = 3000, quadpts = NULL, grsm.block = NULL,
    rsm.block = NULL, prev.mod = NULL, bfactor = FALSE, D =
    1.702, technical = list(), debug = FALSE, verbose =
    TRUE, ...)

## S3 method for class 'MultipleGroupClass': coef(object, digits = 3, verbose = TRUE, ...)

## S3 method for class 'MultipleGroupClass': summary(object, digits = 3, verbose = TRUE, ...)

## S3 method for class 'MultipleGroupClass': anova(object, object2)

Arguments

data
a matrix or data.frame that consists of numerically ordered data, with missing data coded as NA
model
an object or named list of objects returned from confmirt.model() declaring how the factor model is to be estimated. The names of the list input must correspond to the unique values in the group variable. See
group
a character vector indicating group membership
invariance
a character vector containing the following possible options: [object Object],[object Object],[object Object],[object Object],[object Object] Additionally, specifying specific item name bundles (from colnames(data)) will constrain all f
guess
initial (or fixed) values for the pseudo-guessing parameter. Can be entered as a single value to assign a global guessing parameter or may be entered as a numeric vector for each item
upper
initial (or fixed) upper bound parameters for 4-PL model. Can be entered as a single value to assign a global upper bound parameter or may be entered as a numeric vector corresponding to each item
SE
logical; estimate the standard errors? Calls the MHRM subroutine for a stochastic approximation or the Bock and Leiberman method (for EM only)
SE.type
type of estimation method to use for calculating the parameter information matrix. Can be 'MHRM' for stocastic estimation, or 'BL' for the Bock and Leiberman approach (EM only). Note that 'MHRM' may be faster
D
a numeric value used to adjust the logistic metric to be more similar to a normal cumulative density curve. Default is 1.702
SEtol
tollerance value used to stop the MHRM estimation when SE = TRUE. Lower values will take longer but may be more stable for computing the information matrix
verbose
logical; display iteration history during estimation?
draws
the number of Monte Carlo draws to estimate the log-likelihood
quadpts
the number of quadratures to be used per dimensions when method = 'EM'
calcNull
logical; calculate the Null model for fit statics (e.g., TLI)?
bfactor
logical; use the dimensional reduction algorithm if the factor pattern is a bifactor model (has exactly 1 general factor and 1 specific factor for each item). Only applicable when method = 'EM'
prev.mod
an optional input object of class 'MultipleGroupClass' to quickly change the starting values of the current estimation. If a parameter in the current model is being freely estimated then it's value will be set to whatever the correspo
method
a character indicating whether to use the EM ('EM') or the MH-RM ('MHRM') algorithm
itemtype
see mirt for details
constrain
see mirt for details
grsm.block
see mirt for details
rsm.block
see mirt for details
parprior
see mirt for details
pars
see mirt for details
debug
logical; turn on debugging features?
object
an object of class confmirtClass
object2
an object of class confmirtClass
digits
the number of significant digits to be rounded
...
additional arguments to be passed
technical
list specifying subtle parameters that can be adjusted. These values are [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Details

By default the estimation in multipleGroup assumes that the models are maximally independent, and therefore could initially be performed by sub setting the data and running identical models with confmirt or mirt and aggregating the results (e.g., log-likelihood). However, constrains may be imposed across groups by invoking various invariance keywords or by inputing user defined freepars, constrain, and startvalues lists.

See Also

expand.table, key2binary, simdata, confmirt.model, fscores, fitIndices

Examples

Run this code
#single factor
set.seed(12345)
a <- matrix(abs(rnorm(15,1,.3)), ncol=1)
d <- matrix(rnorm(15,0,.7),ncol=1)
itemtype <- rep('dich', nrow(a))
N <- 1000
dataset1 <- simdata(a, d, N, itemtype)
dataset2 <- simdata(a, d, N, itemtype, mu = .1, sigma = matrix(1.5))
dat <- rbind(dataset1, dataset2)
group <- c(rep('D1', N), rep('D2', N))
models <- confmirt.model('F1 = 1-15')

mod_configural <- multipleGroup(dat, models, group = group) #completely seperate analyses

# prev.mod can save precious iterations and help to avoid local minimums
mod_metric <- multipleGroup(dat, models, group = group, invariance=c('slopes'),
                            prev.mod = mod_configural) #equal slopes
mod_scalar2 <- multipleGroup(dat, models, group = group, #equal intercepts, free variance and means
                             invariance=c('slopes', 'intercepts', 'free_varcov','free_means'),
                             prev.mod = mod_configural)
mod_scalar1 <- multipleGroup(dat, models, group = group,  #fixed means
                             invariance=c('slopes', 'intercepts', 'free_varcov'),
                             prev.mod = mod_configural)
mod_fullconstrain <- multipleGroup(dat, models, group = group,
                             invariance=c('slopes', 'intercepts'),
                             prev.mod = mod_configural)

summary(mod_scalar2)
coef(mod_scalar2)
itemplot(mod_configural, 2)
itemplot(mod_configural, 2, type = 'RE')

anova(mod_metric, mod_configural) #equal slopes only
anova(mod_scalar2, mod_metric) #equal intercepts, free variance and mean
anova(mod_scalar1, mod_scalar2) #fix mean
anova(mod_fullconstrain, mod_scalar1) #fix variance


#test whether first 6 slopes should be equal accross groups
values <- multipleGroup(dat, models, group = group, pars = 'values')
values
constrain <- list(c(1, 63), c(5,67), c(9,71), c(13,75), c(17,79), c(21,83))
equalslopes <- multipleGroup(dat, models, group = group, constrain = constrain, )
anova(equalslopes, mod_configural)

#############
#DIF test for each item (using all other items as anchors)
itemnames <- colnames(dat)
refmodel <- multipleGroup(dat, models, group = group,
                             invariance=c('free_means', 'free_varcov', itemnames))

#loop over items (in practice, run in parallel to increase speed)
estmodels <- vector('list', ncol(dat))
for(i in 1:ncol(dat))
    estmodels[[i]] <- multipleGroup(dat, models, group = group, prev.mod=refmodel,
                             invariance=c('free_means', 'free_varcov', itemnames[-i]),
                             verbose = FALSE)

(anovas <- lapply(estmodels, anova, object2=refmodel))

#family-wise error control
p <- do.call(c, lapply(anovas, function(x) x[2,9]))
p.adjust(p, method = 'BH')

#same as above, except only test if slopes vary (1 df)
estmodels <- vector('list', ncol(dat))
for(i in 1:ncol(dat))
    estmodels[[i]] <- multipleGroup(dat, models, group = group, prev.mod=refmodel,
                             invariance=c('free_means', 'free_varcov', 'intercepts', itemnames[-i]),
                             verbose = FALSE)  #constrain all intercepts

(anovas <- lapply(estmodels, anova, object2=refmodel))

#############
#multiple factors

a <- matrix(c(abs(rnorm(5,1,.3)), rep(0,15),abs(rnorm(5,1,.3)),
rep(0,15),abs(rnorm(5,1,.3))), 15, 3)
d <- matrix(rnorm(15,0,.7),ncol=1)
mu <- c(-.4, -.7, .1)
sigma <- matrix(c(1.21,.297,1.232,.297,.81,.252,1.232,.252,1.96),3,3)
itemtype <- rep('dich', nrow(a))
N <- 1000
dataset1 <- simdata(a, d, N, itemtype)
dataset2 <- simdata(a, d, N, itemtype, mu = mu, sigma = sigma)
dat <- rbind(dataset1, dataset2)
group <- c(rep('D1', N), rep('D2', N))

#group models
model1 <- confmirt.model()
   F1 = 1-5
   F2 = 6-10
   F3 = 11-15


model2 <- confmirt.model()
   F1 = 1-5
   F2 = 6-10
   F3 = 11-15
   COV = F1*F2, F1*F3, F2*F3


models <- list(D1=model1, D2=model2) #note the names match the groups

#EM approach (not as accurate with 3 factors, but generally good for quick model comparisons)
mod_configural <- multipleGroup(dat, models, group = group) #completely seperate analyses
mod_metric <- multipleGroup(dat, models, group = group, invariance=c('slopes'),
     prev.mod=mod_configural) #equal slopes
mod_scalar <- multipleGroup(dat, models, group = group, prev.mod=mod_configural, #equal means, slopes, intercepts
                             invariance=c('slopes', 'intercepts', 'free_varcov'))
mod_fullconstrain <- multipleGroup(dat, models, group = group, #equal means, slopes, intercepts
                             invariance=c('slopes', 'intercepts'), prev.mod=mod_configural)

anova(mod_metric, mod_configural)
anova(mod_scalar, mod_metric)
anova(mod_fullconstrain, mod_scalar)

#same as above, but with MHRM (more accurate with 3 factors, but slower)
mod_configural <- multipleGroup(dat, models, group = group, method = 'MHRM') #completely seperate analyses
mod_metric <- multipleGroup(dat, models, group = group, invariance=c('slopes'), method = 'MHRM') #equal slopes
mod_scalar <- multipleGroup(dat, models, group = group, method = 'MHRM', #equal means, slopes, intercepts
                             invariance=c('slopes', 'intercepts', 'free_varcov'))
mod_fullconstrain <- multipleGroup(dat, models, group = group, method = 'MHRM', #equal means, slopes, intercepts
                             invariance=c('slopes', 'intercepts'))

anova(mod_metric, mod_configural)
anova(mod_scalar, mod_metric)
anova(mod_fullconstrain, mod_scalar)

Run the code above in your browser using DataLab