Skip to contents

Initializes the proper S4 class and methods necessary for mirt functions to use in estimation for defining customized group-level functions. To use the defined objects pass to the mirt(..., customGroup = OBJECT) command, and ensure that the class parameters are properly labelled.

Usage

createGroup(
  par,
  est,
  den,
  nfact,
  standardize = FALSE,
  gr = NULL,
  hss = NULL,
  gen = NULL,
  lbound = NULL,
  ubound = NULL,
  derivType = "Richardson"
)

Arguments

par

a named vector of the starting values for the parameters

est

a logical vector indicating which parameters should be freely estimated by default

den

the probability density function given the Theta/ability values. First input contains a vector of all the defined parameters and the second input must be a matrix called Theta. Function also must return a numeric vector object corresponding to the associated densities for each row in the Theta input

nfact

number of factors required for the model. E.g., for unidimensional models with only one dimension of integration nfact = 1

standardize

logical; use standardization of the quadrature table method proposed by Woods and Thissen (2006)? If TRUE, the logical elements named 'MEAN_1' and 'COV_11' can be included in the parameter vector, and when these values are set to FALSE in the est input the E-table will be standardized to these fixed values (e.g., par <- c(a1=1, d=0, MEAN_1=0, COV_11=1) with est <- c(TRUE, TRUE, FALSE, FALSE) will standardize the E-table to have a 0 mean and unit variance)

gr

gradient function (vector of first derivatives) of the log-likelihood used in estimation. The function must be of the form gr(x, Theta), where x is the object defined by createGroup() and Theta is a matrix of latent trait parameters

hss

Hessian function (matrix of second derivatives) of the log-likelihood used in estimation. If not specified a numeric approximation will be used. The input is identical to the gr argument

gen

a function used when GenRandomPars = TRUE is passed to the estimation function to generate random starting values. Function must be of the form function(object) ... and must return a vector with properties equivalent to the par object. If NULL, parameters will remain at the defined starting values by default

lbound

optional vector indicating the lower bounds of the parameters. If not specified then the bounds will be set to -Inf

ubound

optional vector indicating the lower bounds of the parameters. If not specified then the bounds will be set to Inf

derivType

if the gr or hss terms are not specified this type will be used to obtain them numerically. Default is 'Richardson'

References

Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Environment. Journal of Statistical Software, 48(6), 1-29. doi:10.18637/jss.v048.i06

Author

Phil Chalmers rphilip.chalmers@gmail.com

Examples


# normal density example, N(mu, sigma^2)
den <- function(obj, Theta) dnorm(Theta, obj@par[1], sqrt(obj@par[2]))
par <- c(mu = 0, sigma2 = .5)
est <- c(FALSE, TRUE)
lbound <- c(-Inf, 0)
grp <- createGroup(par, est, den, nfact = 1, lbound=lbound)

dat <- expand.table(LSAT6)
mod <- mirt(dat, 1, 'Rasch')
#> 
Iteration: 1, Log-Lik: -2473.219, Max-Change: 0.05796
Iteration: 2, Log-Lik: -2471.905, Max-Change: 0.03951
Iteration: 3, Log-Lik: -2471.040, Max-Change: 0.03366
Iteration: 4, Log-Lik: -2470.482, Max-Change: 0.03644
Iteration: 5, Log-Lik: -2469.693, Max-Change: 0.02589
Iteration: 6, Log-Lik: -2469.238, Max-Change: 0.02212
Iteration: 7, Log-Lik: -2468.875, Max-Change: 0.01999
Iteration: 8, Log-Lik: -2468.573, Max-Change: 0.01718
Iteration: 9, Log-Lik: -2468.329, Max-Change: 0.01528
Iteration: 10, Log-Lik: -2468.157, Max-Change: 0.01747
Iteration: 11, Log-Lik: -2467.932, Max-Change: 0.01255
Iteration: 12, Log-Lik: -2467.788, Max-Change: 0.01111
Iteration: 13, Log-Lik: -2467.669, Max-Change: 0.01035
Iteration: 14, Log-Lik: -2467.565, Max-Change: 0.00911
Iteration: 15, Log-Lik: -2467.480, Max-Change: 0.00826
Iteration: 16, Log-Lik: -2467.417, Max-Change: 0.00959
Iteration: 17, Log-Lik: -2467.338, Max-Change: 0.00701
Iteration: 18, Log-Lik: -2467.285, Max-Change: 0.00633
Iteration: 19, Log-Lik: -2467.240, Max-Change: 0.00600
Iteration: 20, Log-Lik: -2467.199, Max-Change: 0.00534
Iteration: 21, Log-Lik: -2467.166, Max-Change: 0.00490
Iteration: 22, Log-Lik: -2467.141, Max-Change: 0.00570
Iteration: 23, Log-Lik: -2467.109, Max-Change: 0.00424
Iteration: 24, Log-Lik: -2467.088, Max-Change: 0.00387
Iteration: 25, Log-Lik: -2467.069, Max-Change: 0.00370
Iteration: 26, Log-Lik: -2467.052, Max-Change: 0.00332
Iteration: 27, Log-Lik: -2467.038, Max-Change: 0.00307
Iteration: 28, Log-Lik: -2467.027, Max-Change: 0.00356
Iteration: 29, Log-Lik: -2467.014, Max-Change: 0.00269
Iteration: 30, Log-Lik: -2467.005, Max-Change: 0.00247
Iteration: 31, Log-Lik: -2466.997, Max-Change: 0.00238
Iteration: 32, Log-Lik: -2466.989, Max-Change: 0.00214
Iteration: 33, Log-Lik: -2466.983, Max-Change: 0.00199
Iteration: 34, Log-Lik: -2466.978, Max-Change: 0.00231
Iteration: 35, Log-Lik: -2466.973, Max-Change: 0.00176
Iteration: 36, Log-Lik: -2466.968, Max-Change: 0.00162
Iteration: 37, Log-Lik: -2466.965, Max-Change: 0.00157
Iteration: 38, Log-Lik: -2466.961, Max-Change: 0.00141
Iteration: 39, Log-Lik: -2466.959, Max-Change: 0.00132
Iteration: 40, Log-Lik: -2466.956, Max-Change: 0.00153
Iteration: 41, Log-Lik: -2466.954, Max-Change: 0.00117
Iteration: 42, Log-Lik: -2466.952, Max-Change: 0.00108
Iteration: 43, Log-Lik: -2466.950, Max-Change: 0.00105
Iteration: 44, Log-Lik: -2466.949, Max-Change: 0.00095
Iteration: 45, Log-Lik: -2466.947, Max-Change: 0.00089
Iteration: 46, Log-Lik: -2466.946, Max-Change: 0.00108
Iteration: 47, Log-Lik: -2466.945, Max-Change: 0.00079
Iteration: 48, Log-Lik: -2466.944, Max-Change: 0.00073
Iteration: 49, Log-Lik: -2466.944, Max-Change: 0.00070
Iteration: 50, Log-Lik: -2466.943, Max-Change: 0.00065
Iteration: 51, Log-Lik: -2466.942, Max-Change: 0.00060
Iteration: 52, Log-Lik: -2466.942, Max-Change: 0.00071
Iteration: 53, Log-Lik: -2466.941, Max-Change: 0.00054
Iteration: 54, Log-Lik: -2466.941, Max-Change: 0.00050
Iteration: 55, Log-Lik: -2466.940, Max-Change: 0.00048
Iteration: 56, Log-Lik: -2466.940, Max-Change: 0.00044
Iteration: 57, Log-Lik: -2466.940, Max-Change: 0.00041
Iteration: 58, Log-Lik: -2466.940, Max-Change: 0.00053
Iteration: 59, Log-Lik: -2466.939, Max-Change: 0.00037
Iteration: 60, Log-Lik: -2466.939, Max-Change: 0.00034
Iteration: 61, Log-Lik: -2466.939, Max-Change: 0.00033
Iteration: 62, Log-Lik: -2466.939, Max-Change: 0.00030
Iteration: 63, Log-Lik: -2466.939, Max-Change: 0.00028
Iteration: 64, Log-Lik: -2466.939, Max-Change: 0.00032
Iteration: 65, Log-Lik: -2466.938, Max-Change: 0.00025
Iteration: 66, Log-Lik: -2466.938, Max-Change: 0.00023
Iteration: 67, Log-Lik: -2466.938, Max-Change: 0.00022
Iteration: 68, Log-Lik: -2466.938, Max-Change: 0.00020
Iteration: 69, Log-Lik: -2466.938, Max-Change: 0.00019
Iteration: 70, Log-Lik: -2466.938, Max-Change: 0.00024
Iteration: 71, Log-Lik: -2466.938, Max-Change: 0.00017
Iteration: 72, Log-Lik: -2466.938, Max-Change: 0.00016
Iteration: 73, Log-Lik: -2466.938, Max-Change: 0.00016
Iteration: 74, Log-Lik: -2466.938, Max-Change: 0.00014
Iteration: 75, Log-Lik: -2466.938, Max-Change: 0.00013
Iteration: 76, Log-Lik: -2466.938, Max-Change: 0.00017
Iteration: 77, Log-Lik: -2466.938, Max-Change: 0.00012
Iteration: 78, Log-Lik: -2466.938, Max-Change: 0.00011
Iteration: 79, Log-Lik: -2466.938, Max-Change: 0.00011
Iteration: 80, Log-Lik: -2466.938, Max-Change: 0.00010
modcustom <- mirt(dat, 1, 'Rasch', customGroup=grp)
#> 
Iteration: 1, Log-Lik: -2469.780, Max-Change: 0.11152
Iteration: 2, Log-Lik: -2467.243, Max-Change: 0.01652
Iteration: 3, Log-Lik: -2467.096, Max-Change: 0.00440
Iteration: 4, Log-Lik: -2467.075, Max-Change: 0.00328
Iteration: 5, Log-Lik: -2467.057, Max-Change: 0.00264
Iteration: 6, Log-Lik: -2467.044, Max-Change: 0.00248
Iteration: 7, Log-Lik: -2467.033, Max-Change: 0.00237
Iteration: 8, Log-Lik: -2467.023, Max-Change: 0.00224
Iteration: 9, Log-Lik: -2467.014, Max-Change: 0.00212
Iteration: 10, Log-Lik: -2467.007, Max-Change: 0.00268
Iteration: 11, Log-Lik: -2466.998, Max-Change: 0.00195
Iteration: 12, Log-Lik: -2466.992, Max-Change: 0.00183
Iteration: 13, Log-Lik: -2466.986, Max-Change: 0.00180
Iteration: 14, Log-Lik: -2466.981, Max-Change: 0.00166
Iteration: 15, Log-Lik: -2466.976, Max-Change: 0.00157
Iteration: 16, Log-Lik: -2466.973, Max-Change: 0.00175
Iteration: 17, Log-Lik: -2466.968, Max-Change: 0.00142
Iteration: 18, Log-Lik: -2466.965, Max-Change: 0.00133
Iteration: 19, Log-Lik: -2466.962, Max-Change: 0.00131
Iteration: 20, Log-Lik: -2466.959, Max-Change: 0.00120
Iteration: 21, Log-Lik: -2466.957, Max-Change: 0.00113
Iteration: 22, Log-Lik: -2466.955, Max-Change: 0.00130
Iteration: 23, Log-Lik: -2466.953, Max-Change: 0.00102
Iteration: 24, Log-Lik: -2466.951, Max-Change: 0.00096
Iteration: 25, Log-Lik: -2466.950, Max-Change: 0.00093
Iteration: 26, Log-Lik: -2466.948, Max-Change: 0.00085
Iteration: 27, Log-Lik: -2466.947, Max-Change: 0.00080
Iteration: 28, Log-Lik: -2466.946, Max-Change: 0.00095
Iteration: 29, Log-Lik: -2466.945, Max-Change: 0.00073
Iteration: 30, Log-Lik: -2466.944, Max-Change: 0.00068
Iteration: 31, Log-Lik: -2466.943, Max-Change: 0.00066
Iteration: 32, Log-Lik: -2466.943, Max-Change: 0.00060
Iteration: 33, Log-Lik: -2466.942, Max-Change: 0.00057
Iteration: 34, Log-Lik: -2466.942, Max-Change: 0.00071
Iteration: 35, Log-Lik: -2466.941, Max-Change: 0.00051
Iteration: 36, Log-Lik: -2466.941, Max-Change: 0.00047
Iteration: 37, Log-Lik: -2466.940, Max-Change: 0.00046
Iteration: 38, Log-Lik: -2466.940, Max-Change: 0.00043
Iteration: 39, Log-Lik: -2466.940, Max-Change: 0.00040
Iteration: 40, Log-Lik: -2466.940, Max-Change: 0.00042
Iteration: 41, Log-Lik: -2466.939, Max-Change: 0.00036
Iteration: 42, Log-Lik: -2466.939, Max-Change: 0.00034
Iteration: 43, Log-Lik: -2466.939, Max-Change: 0.00033
Iteration: 44, Log-Lik: -2466.939, Max-Change: 0.00030
Iteration: 45, Log-Lik: -2466.939, Max-Change: 0.00028
Iteration: 46, Log-Lik: -2466.939, Max-Change: 0.00041
Iteration: 47, Log-Lik: -2466.938, Max-Change: 0.00025
Iteration: 48, Log-Lik: -2466.938, Max-Change: 0.00023
Iteration: 49, Log-Lik: -2466.938, Max-Change: 0.00022
Iteration: 50, Log-Lik: -2466.938, Max-Change: 0.00021
Iteration: 51, Log-Lik: -2466.938, Max-Change: 0.00019
Iteration: 52, Log-Lik: -2466.938, Max-Change: 0.00025
Iteration: 53, Log-Lik: -2466.938, Max-Change: 0.00018
Iteration: 54, Log-Lik: -2466.938, Max-Change: 0.00016
Iteration: 55, Log-Lik: -2466.938, Max-Change: 0.00016
Iteration: 56, Log-Lik: -2466.938, Max-Change: 0.00014
Iteration: 57, Log-Lik: -2466.938, Max-Change: 0.00013
Iteration: 58, Log-Lik: -2466.938, Max-Change: 0.00013
Iteration: 59, Log-Lik: -2466.938, Max-Change: 0.00012
Iteration: 60, Log-Lik: -2466.938, Max-Change: 0.00011
Iteration: 61, Log-Lik: -2466.938, Max-Change: 0.00011
Iteration: 62, Log-Lik: -2466.938, Max-Change: 0.00010

coef(mod)
#> $Item_1
#>     a1     d g u
#> par  1 2.731 0 1
#> 
#> $Item_2
#>     a1     d g u
#> par  1 0.999 0 1
#> 
#> $Item_3
#>     a1    d g u
#> par  1 0.24 0 1
#> 
#> $Item_4
#>     a1     d g u
#> par  1 1.307 0 1
#> 
#> $Item_5
#>     a1   d g u
#> par  1 2.1 0 1
#> 
#> $GroupPars
#>     MEAN_1 COV_11
#> par      0  0.572
#> 
coef(modcustom)
#> $Item_1
#>     a1     d g u
#> par  1 2.729 0 1
#> 
#> $Item_2
#>     a1     d g u
#> par  1 0.998 0 1
#> 
#> $Item_3
#>     a1    d g u
#> par  1 0.24 0 1
#> 
#> $Item_4
#>     a1     d g u
#> par  1 1.306 0 1
#> 
#> $Item_5
#>     a1     d g u
#> par  1 2.099 0 1
#> 
#> $GroupPars
#>     mu sigma2
#> par  0  0.569
#>