A function for extracting the empirical estimating functions of a fitted
mirt
, multipleGroup
, bfactor
, or
mdirt
model. This is the derivative of the log-likelihood with respect to the
parameter vector, evaluated at the observed (case-wise) data. In other
words, this function returns the case-wise scores, evaluated at the fitted
model parameters. Currently, models fitted via the EM
or BL
method are supported. For the computations, the internal Theta
grid of
the model is being used which was already used during the estimation of
the model itself along with its matching normalized density.
Usage
estfun.AllModelClass(
x,
weights = extract.mirt(x, "survey.weights"),
centering = FALSE
)
Arguments
- x
a fitted model object of class
SingleGroupClass
,MultipleGroupClass
, orDiscreteClass
- weights
by default, the
survey.weights
which were (optionally) specified when fitting the model are included to calculate the scores. If specified by the user, this should be a numeric vector of length equal to the total sample size. Note that if not all cases were weighted equally when fitting the model, the weights must be corrected by taking their square root if the scores are being used to compute the outer product of gradients (OPG) estimate of the variance-covariance matrix (see examples below).- centering
a boolean variable that allows the centering of the case-wise scores (i.e., setting their expected values to 0). If the case-wise scores were obtained from maximum likelihood estimates, this setting does not affect the result.
Author
Lennart Schneider lennart.sch@web.de and Phil Chalmers; centering argument contributed by Rudolf Debelak (rudolf.debelak@psychologie.uzh.ch)
Examples
# \donttest{
# fit a 2PL on the LSAT7 data and get the scores
mod1 <- mirt(expand.table(LSAT7), 1, SE = TRUE, SE.type = "crossprod")
#>
Iteration: 1, Log-Lik: -2668.786, Max-Change: 0.18243
Iteration: 2, Log-Lik: -2663.691, Max-Change: 0.13637
Iteration: 3, Log-Lik: -2661.454, Max-Change: 0.10231
Iteration: 4, Log-Lik: -2659.430, Max-Change: 0.04181
Iteration: 5, Log-Lik: -2659.241, Max-Change: 0.03417
Iteration: 6, Log-Lik: -2659.113, Max-Change: 0.02911
Iteration: 7, Log-Lik: -2658.812, Max-Change: 0.00456
Iteration: 8, Log-Lik: -2658.809, Max-Change: 0.00363
Iteration: 9, Log-Lik: -2658.808, Max-Change: 0.00273
Iteration: 10, Log-Lik: -2658.806, Max-Change: 0.00144
Iteration: 11, Log-Lik: -2658.806, Max-Change: 0.00118
Iteration: 12, Log-Lik: -2658.806, Max-Change: 0.00101
Iteration: 13, Log-Lik: -2658.805, Max-Change: 0.00042
Iteration: 14, Log-Lik: -2658.805, Max-Change: 0.00025
Iteration: 15, Log-Lik: -2658.805, Max-Change: 0.00026
Iteration: 16, Log-Lik: -2658.805, Max-Change: 0.00023
Iteration: 17, Log-Lik: -2658.805, Max-Change: 0.00023
Iteration: 18, Log-Lik: -2658.805, Max-Change: 0.00021
Iteration: 19, Log-Lik: -2658.805, Max-Change: 0.00019
Iteration: 20, Log-Lik: -2658.805, Max-Change: 0.00017
Iteration: 21, Log-Lik: -2658.805, Max-Change: 0.00017
Iteration: 22, Log-Lik: -2658.805, Max-Change: 0.00015
Iteration: 23, Log-Lik: -2658.805, Max-Change: 0.00015
Iteration: 24, Log-Lik: -2658.805, Max-Change: 0.00013
Iteration: 25, Log-Lik: -2658.805, Max-Change: 0.00013
Iteration: 26, Log-Lik: -2658.805, Max-Change: 0.00011
Iteration: 27, Log-Lik: -2658.805, Max-Change: 0.00011
Iteration: 28, Log-Lik: -2658.805, Max-Change: 0.00010
#>
#> Calculating information matrix...
sc1 <- estfun.AllModelClass(mod1)
# get the gradient
colSums(sc1)
#> a1.1 d.2 a1.5 d.6 a1.9
#> -2.477600e-03 -1.749068e-03 8.292831e-05 -1.521604e-03 1.198404e-02
#> d.10 a1.13 d.14 a1.17 d.18
#> 6.498262e-03 -2.188204e-03 4.417930e-03 -8.004882e-04 -5.566577e-04
# calculate the OPG estimate of the variance-covariance matrix "by hand"
vc1 <- vcov(mod1)
all.equal(crossprod(sc1), chol2inv(chol(vc1)), check.attributes = FALSE)
#> [1] TRUE
# Discrete group
modd <- mdirt(expand.table(LSAT7), 2, SE = TRUE, SE.type = "crossprod")
#>
Iteration: 1, Log-Lik: -3172.670, Max-Change: 1.98698
Iteration: 2, Log-Lik: -2669.760, Max-Change: 0.19773
Iteration: 3, Log-Lik: -2665.524, Max-Change: 0.09790
Iteration: 4, Log-Lik: -2664.758, Max-Change: 0.07657
Iteration: 5, Log-Lik: -2664.107, Max-Change: 0.05542
Iteration: 6, Log-Lik: -2663.654, Max-Change: 0.04673
Iteration: 7, Log-Lik: -2663.090, Max-Change: 0.07052
Iteration: 8, Log-Lik: -2662.536, Max-Change: 0.02231
Iteration: 9, Log-Lik: -2662.356, Max-Change: 0.02390
Iteration: 10, Log-Lik: -2662.354, Max-Change: 0.07397
Iteration: 11, Log-Lik: -2661.679, Max-Change: 0.01862
Iteration: 12, Log-Lik: -2661.566, Max-Change: 0.01748
Iteration: 13, Log-Lik: -2661.563, Max-Change: 0.05606
Iteration: 14, Log-Lik: -2661.160, Max-Change: 0.01363
Iteration: 15, Log-Lik: -2661.094, Max-Change: 0.01254
Iteration: 16, Log-Lik: -2661.121, Max-Change: 0.04503
Iteration: 17, Log-Lik: -2660.841, Max-Change: 0.01282
Iteration: 18, Log-Lik: -2660.796, Max-Change: 0.00970
Iteration: 19, Log-Lik: -2660.785, Max-Change: 0.03175
Iteration: 20, Log-Lik: -2660.651, Max-Change: 0.00797
Iteration: 21, Log-Lik: -2660.625, Max-Change: 0.00807
Iteration: 22, Log-Lik: -2660.630, Max-Change: 0.02762
Iteration: 23, Log-Lik: -2660.525, Max-Change: 0.00560
Iteration: 24, Log-Lik: -2660.510, Max-Change: 0.00828
Iteration: 25, Log-Lik: -2660.489, Max-Change: 0.01534
Iteration: 26, Log-Lik: -2660.455, Max-Change: 0.00645
Iteration: 27, Log-Lik: -2660.442, Max-Change: 0.00486
Iteration: 28, Log-Lik: -2660.434, Max-Change: 0.01366
Iteration: 29, Log-Lik: -2660.407, Max-Change: 0.00386
Iteration: 30, Log-Lik: -2660.400, Max-Change: 0.00455
Iteration: 31, Log-Lik: -2660.396, Max-Change: 0.01350
Iteration: 32, Log-Lik: -2660.371, Max-Change: 0.00430
Iteration: 33, Log-Lik: -2660.366, Max-Change: 0.00360
Iteration: 34, Log-Lik: -2660.361, Max-Change: 0.00882
Iteration: 35, Log-Lik: -2660.350, Max-Change: 0.00295
Iteration: 36, Log-Lik: -2660.347, Max-Change: 0.00286
Iteration: 37, Log-Lik: -2660.343, Max-Change: 0.00351
Iteration: 38, Log-Lik: -2660.340, Max-Change: 0.00258
Iteration: 39, Log-Lik: -2660.337, Max-Change: 0.00280
Iteration: 40, Log-Lik: -2660.334, Max-Change: 0.00501
Iteration: 41, Log-Lik: -2660.330, Max-Change: 0.00221
Iteration: 42, Log-Lik: -2660.328, Max-Change: 0.00231
Iteration: 43, Log-Lik: -2660.325, Max-Change: 0.00459
Iteration: 44, Log-Lik: -2660.322, Max-Change: 0.00202
Iteration: 45, Log-Lik: -2660.320, Max-Change: 0.00187
Iteration: 46, Log-Lik: -2660.319, Max-Change: 0.00310
Iteration: 47, Log-Lik: -2660.317, Max-Change: 0.00217
Iteration: 48, Log-Lik: -2660.315, Max-Change: 0.00169
Iteration: 49, Log-Lik: -2660.314, Max-Change: 0.00163
Iteration: 50, Log-Lik: -2660.313, Max-Change: 0.00259
Iteration: 51, Log-Lik: -2660.312, Max-Change: 0.00259
Iteration: 52, Log-Lik: -2660.311, Max-Change: 0.00221
Iteration: 53, Log-Lik: -2660.310, Max-Change: 0.00244
Iteration: 54, Log-Lik: -2660.309, Max-Change: 0.00212
Iteration: 55, Log-Lik: -2660.309, Max-Change: 0.00222
Iteration: 56, Log-Lik: -2660.308, Max-Change: 0.00201
Iteration: 57, Log-Lik: -2660.307, Max-Change: 0.00212
Iteration: 58, Log-Lik: -2660.307, Max-Change: 0.00190
Iteration: 59, Log-Lik: -2660.306, Max-Change: 0.00198
Iteration: 60, Log-Lik: -2660.305, Max-Change: 0.00180
Iteration: 61, Log-Lik: -2660.305, Max-Change: 0.00182
Iteration: 62, Log-Lik: -2660.304, Max-Change: 0.00170
Iteration: 63, Log-Lik: -2660.304, Max-Change: 0.00174
Iteration: 64, Log-Lik: -2660.303, Max-Change: 0.00160
Iteration: 65, Log-Lik: -2660.303, Max-Change: 0.00163
Iteration: 66, Log-Lik: -2660.303, Max-Change: 0.00151
Iteration: 67, Log-Lik: -2660.302, Max-Change: 0.00150
Iteration: 68, Log-Lik: -2660.302, Max-Change: 0.00142
Iteration: 69, Log-Lik: -2660.302, Max-Change: 0.00143
Iteration: 70, Log-Lik: -2660.301, Max-Change: 0.00133
Iteration: 71, Log-Lik: -2660.301, Max-Change: 0.00134
Iteration: 72, Log-Lik: -2660.301, Max-Change: 0.00126
Iteration: 73, Log-Lik: -2660.301, Max-Change: 0.00124
Iteration: 74, Log-Lik: -2660.300, Max-Change: 0.00118
Iteration: 75, Log-Lik: -2660.300, Max-Change: 0.00118
Iteration: 76, Log-Lik: -2660.300, Max-Change: 0.00110
Iteration: 77, Log-Lik: -2660.300, Max-Change: 0.00111
Iteration: 78, Log-Lik: -2660.300, Max-Change: 0.00104
Iteration: 79, Log-Lik: -2660.299, Max-Change: 0.00102
Iteration: 80, Log-Lik: -2660.299, Max-Change: 0.00098
Iteration: 81, Log-Lik: -2660.299, Max-Change: 0.00097
Iteration: 82, Log-Lik: -2660.299, Max-Change: 0.00092
Iteration: 83, Log-Lik: -2660.299, Max-Change: 0.00091
Iteration: 84, Log-Lik: -2660.299, Max-Change: 0.00086
Iteration: 85, Log-Lik: -2660.299, Max-Change: 0.00084
Iteration: 86, Log-Lik: -2660.298, Max-Change: 0.00081
Iteration: 87, Log-Lik: -2660.298, Max-Change: 0.00080
Iteration: 88, Log-Lik: -2660.298, Max-Change: 0.00076
Iteration: 89, Log-Lik: -2660.298, Max-Change: 0.00075
Iteration: 90, Log-Lik: -2660.298, Max-Change: 0.00072
Iteration: 91, Log-Lik: -2660.298, Max-Change: 0.00069
Iteration: 92, Log-Lik: -2660.298, Max-Change: 0.00067
Iteration: 93, Log-Lik: -2660.298, Max-Change: 0.00066
Iteration: 94, Log-Lik: -2660.298, Max-Change: 0.00063
Iteration: 95, Log-Lik: -2660.298, Max-Change: 0.00062
Iteration: 96, Log-Lik: -2660.298, Max-Change: 0.00059
Iteration: 97, Log-Lik: -2660.298, Max-Change: 0.00057
Iteration: 98, Log-Lik: -2660.298, Max-Change: 0.00055
Iteration: 99, Log-Lik: -2660.298, Max-Change: 0.00055
Iteration: 100, Log-Lik: -2660.297, Max-Change: 0.00000
#>
#> Calculating information matrix...
sc1 <- estfun.AllModelClass(modd)
# get the gradient
colSums(sc1)
#> a1.1 a2.2 a1.3 a2.4 a1.5 a2.6
#> 0.010556101 0.012533394 0.015994245 0.016832573 0.021043233 0.020842514
#> a1.7 a2.8 a1.9 a2.10 c1.11
#> 0.013694253 0.011470847 0.007827056 0.009231532 0.059032788
# calculate the OPG estimate of the variance-covariance matrix "by hand"
vc1 <- vcov(modd)
all.equal(crossprod(sc1), chol2inv(chol(vc1)), check.attributes = FALSE)
#> [1] TRUE
# fit a multiple group 2PL and do the same as above
group <- rep(c("G1", "G2"), 500)
mod2 <- multipleGroup(expand.table(LSAT7), 1, group, SE = TRUE,
SE.type = "crossprod")
#>
Iteration: 1, Log-Lik: -2668.786, Max-Change: 0.19735
Iteration: 2, Log-Lik: -2663.614, Max-Change: 0.14597
Iteration: 3, Log-Lik: -2661.372, Max-Change: 0.10785
Iteration: 4, Log-Lik: -2659.391, Max-Change: 0.05318
Iteration: 5, Log-Lik: -2659.170, Max-Change: 0.04533
Iteration: 6, Log-Lik: -2659.027, Max-Change: 0.03795
Iteration: 7, Log-Lik: -2658.706, Max-Change: 0.01028
Iteration: 8, Log-Lik: -2658.699, Max-Change: 0.00923
Iteration: 9, Log-Lik: -2658.694, Max-Change: 0.00815
Iteration: 10, Log-Lik: -2658.683, Max-Change: 0.00317
Iteration: 11, Log-Lik: -2658.683, Max-Change: 0.00235
Iteration: 12, Log-Lik: -2658.682, Max-Change: 0.00051
Iteration: 13, Log-Lik: -2658.682, Max-Change: 0.00049
Iteration: 14, Log-Lik: -2658.682, Max-Change: 0.00204
Iteration: 15, Log-Lik: -2658.682, Max-Change: 0.00161
Iteration: 16, Log-Lik: -2658.682, Max-Change: 0.00032
Iteration: 17, Log-Lik: -2658.682, Max-Change: 0.00124
Iteration: 18, Log-Lik: -2658.682, Max-Change: 0.00124
Iteration: 19, Log-Lik: -2658.682, Max-Change: 0.00033
Iteration: 20, Log-Lik: -2658.682, Max-Change: 0.00021
Iteration: 21, Log-Lik: -2658.682, Max-Change: 0.00088
Iteration: 22, Log-Lik: -2658.682, Max-Change: 0.00018
Iteration: 23, Log-Lik: -2658.682, Max-Change: 0.00057
Iteration: 24, Log-Lik: -2658.682, Max-Change: 0.00016
Iteration: 25, Log-Lik: -2658.682, Max-Change: 0.00015
Iteration: 26, Log-Lik: -2658.682, Max-Change: 0.00063
Iteration: 27, Log-Lik: -2658.682, Max-Change: 0.00054
Iteration: 28, Log-Lik: -2658.682, Max-Change: 0.00016
Iteration: 29, Log-Lik: -2658.682, Max-Change: 0.00011
Iteration: 30, Log-Lik: -2658.682, Max-Change: 0.00046
Iteration: 31, Log-Lik: -2658.682, Max-Change: 0.00009
#>
#> Calculating information matrix...
sc2 <- estfun.AllModelClass(mod2)
colSums(sc2)
#> a1.1 d.2 a1.5 d.6 a1.9
#> -3.118728e-04 -2.982410e-03 -2.735485e-04 -6.118069e-04 7.440279e-03
#> d.10 a1.13 d.14 a1.17 d.18
#> 7.274125e-03 -9.423217e-04 -3.379603e-04 6.496281e-04 -1.868471e-03
#> a1.23 d.24 a1.27 d.28 a1.31
#> -1.197098e-04 -4.435649e-04 -2.378475e-05 1.458023e-04 6.403262e-04
#> d.32 a1.35 d.36 a1.39 d.40
#> 1.212925e-03 -1.443583e-04 4.381246e-05 4.279434e-04 -9.488836e-04
vc2 <- vcov(mod2)
all.equal(crossprod(sc2), chol2inv(chol(vc2)), check.attributes = FALSE)
#> [1] TRUE
# fit a bifactor model with 2 specific factors and do the same as above
mod3 <- bfactor(expand.table(LSAT7), c(2, 2, 1, 1, 2), SE = TRUE,
SE.type = "crossprod")
#>
Iteration: 1, Log-Lik: -2694.344, Max-Change: 0.36688
Iteration: 2, Log-Lik: -2669.215, Max-Change: 0.14890
Iteration: 3, Log-Lik: -2664.172, Max-Change: 0.10192
Iteration: 4, Log-Lik: -2662.296, Max-Change: 0.08055
Iteration: 5, Log-Lik: -2661.306, Max-Change: 0.06530
Iteration: 6, Log-Lik: -2660.668, Max-Change: 0.05326
Iteration: 7, Log-Lik: -2659.085, Max-Change: 0.02423
Iteration: 8, Log-Lik: -2658.892, Max-Change: 0.02397
Iteration: 9, Log-Lik: -2658.713, Max-Change: 0.02346
Iteration: 10, Log-Lik: -2657.751, Max-Change: 0.01958
Iteration: 11, Log-Lik: -2657.588, Max-Change: 0.01984
Iteration: 12, Log-Lik: -2657.431, Max-Change: 0.01906
Iteration: 13, Log-Lik: -2656.640, Max-Change: 0.01475
Iteration: 14, Log-Lik: -2656.553, Max-Change: 0.01381
Iteration: 15, Log-Lik: -2656.479, Max-Change: 0.01312
Iteration: 16, Log-Lik: -2656.168, Max-Change: 0.00850
Iteration: 17, Log-Lik: -2656.144, Max-Change: 0.00830
Iteration: 18, Log-Lik: -2656.123, Max-Change: 0.00800
Iteration: 19, Log-Lik: -2656.029, Max-Change: 0.00537
Iteration: 20, Log-Lik: -2656.020, Max-Change: 0.00528
Iteration: 21, Log-Lik: -2656.011, Max-Change: 0.00516
Iteration: 22, Log-Lik: -2655.965, Max-Change: 0.00452
Iteration: 23, Log-Lik: -2655.959, Max-Change: 0.00442
Iteration: 24, Log-Lik: -2655.954, Max-Change: 0.00432
Iteration: 25, Log-Lik: -2655.923, Max-Change: 0.00374
Iteration: 26, Log-Lik: -2655.919, Max-Change: 0.00365
Iteration: 27, Log-Lik: -2655.915, Max-Change: 0.00357
Iteration: 28, Log-Lik: -2655.893, Max-Change: 0.00309
Iteration: 29, Log-Lik: -2655.890, Max-Change: 0.00306
Iteration: 30, Log-Lik: -2655.887, Max-Change: 0.00300
Iteration: 31, Log-Lik: -2655.873, Max-Change: 0.00264
Iteration: 32, Log-Lik: -2655.871, Max-Change: 0.00258
Iteration: 33, Log-Lik: -2655.869, Max-Change: 0.00253
Iteration: 34, Log-Lik: -2655.858, Max-Change: 0.00218
Iteration: 35, Log-Lik: -2655.857, Max-Change: 0.00215
Iteration: 36, Log-Lik: -2655.856, Max-Change: 0.00212
Iteration: 37, Log-Lik: -2655.849, Max-Change: 0.00165
Iteration: 38, Log-Lik: -2655.848, Max-Change: 0.00205
Iteration: 39, Log-Lik: -2655.847, Max-Change: 0.00195
Iteration: 40, Log-Lik: -2655.841, Max-Change: 0.00158
Iteration: 41, Log-Lik: -2655.841, Max-Change: 0.00157
Iteration: 42, Log-Lik: -2655.840, Max-Change: 0.00154
Iteration: 43, Log-Lik: -2655.837, Max-Change: 0.00138
Iteration: 44, Log-Lik: -2655.836, Max-Change: 0.00134
Iteration: 45, Log-Lik: -2655.836, Max-Change: 0.00131
Iteration: 46, Log-Lik: -2655.833, Max-Change: 0.00113
Iteration: 47, Log-Lik: -2655.833, Max-Change: 0.00111
Iteration: 48, Log-Lik: -2655.832, Max-Change: 0.00109
Iteration: 49, Log-Lik: -2655.831, Max-Change: 0.00097
Iteration: 50, Log-Lik: -2655.830, Max-Change: 0.00094
Iteration: 51, Log-Lik: -2655.830, Max-Change: 0.00093
Iteration: 52, Log-Lik: -2655.829, Max-Change: 0.00081
Iteration: 53, Log-Lik: -2655.829, Max-Change: 0.00080
Iteration: 54, Log-Lik: -2655.828, Max-Change: 0.00079
Iteration: 55, Log-Lik: -2655.827, Max-Change: 0.00070
Iteration: 56, Log-Lik: -2655.827, Max-Change: 0.00069
Iteration: 57, Log-Lik: -2655.827, Max-Change: 0.00068
Iteration: 58, Log-Lik: -2655.826, Max-Change: 0.00062
Iteration: 59, Log-Lik: -2655.826, Max-Change: 0.00061
Iteration: 60, Log-Lik: -2655.826, Max-Change: 0.00060
Iteration: 61, Log-Lik: -2655.826, Max-Change: 0.00055
Iteration: 62, Log-Lik: -2655.826, Max-Change: 0.00055
Iteration: 63, Log-Lik: -2655.826, Max-Change: 0.00054
Iteration: 64, Log-Lik: -2655.825, Max-Change: 0.00050
Iteration: 65, Log-Lik: -2655.825, Max-Change: 0.00046
Iteration: 66, Log-Lik: -2655.825, Max-Change: 0.00043
Iteration: 67, Log-Lik: -2655.825, Max-Change: 0.00041
Iteration: 68, Log-Lik: -2655.825, Max-Change: 0.00040
Iteration: 69, Log-Lik: -2655.825, Max-Change: 0.00040
Iteration: 70, Log-Lik: -2655.824, Max-Change: 0.00037
Iteration: 71, Log-Lik: -2655.824, Max-Change: 0.00037
Iteration: 72, Log-Lik: -2655.824, Max-Change: 0.00036
Iteration: 73, Log-Lik: -2655.824, Max-Change: 0.00036
Iteration: 74, Log-Lik: -2655.824, Max-Change: 0.00035
Iteration: 75, Log-Lik: -2655.824, Max-Change: 0.00035
Iteration: 76, Log-Lik: -2655.824, Max-Change: 0.00034
Iteration: 77, Log-Lik: -2655.824, Max-Change: 0.00034
Iteration: 78, Log-Lik: -2655.824, Max-Change: 0.00033
Iteration: 79, Log-Lik: -2655.824, Max-Change: 0.00033
Iteration: 80, Log-Lik: -2655.824, Max-Change: 0.00032
Iteration: 81, Log-Lik: -2655.824, Max-Change: 0.00032
Iteration: 82, Log-Lik: -2655.824, Max-Change: 0.00031
Iteration: 83, Log-Lik: -2655.824, Max-Change: 0.00031
Iteration: 84, Log-Lik: -2655.824, Max-Change: 0.00030
Iteration: 85, Log-Lik: -2655.824, Max-Change: 0.00030
Iteration: 86, Log-Lik: -2655.824, Max-Change: 0.00029
Iteration: 87, Log-Lik: -2655.824, Max-Change: 0.00029
Iteration: 88, Log-Lik: -2655.824, Max-Change: 0.00028
Iteration: 89, Log-Lik: -2655.824, Max-Change: 0.00028
Iteration: 90, Log-Lik: -2655.823, Max-Change: 0.00028
Iteration: 91, Log-Lik: -2655.823, Max-Change: 0.00027
Iteration: 92, Log-Lik: -2655.823, Max-Change: 0.00027
Iteration: 93, Log-Lik: -2655.823, Max-Change: 0.00027
Iteration: 94, Log-Lik: -2655.823, Max-Change: 0.00026
Iteration: 95, Log-Lik: -2655.823, Max-Change: 0.00026
Iteration: 96, Log-Lik: -2655.823, Max-Change: 0.00026
Iteration: 97, Log-Lik: -2655.823, Max-Change: 0.00025
Iteration: 98, Log-Lik: -2655.823, Max-Change: 0.00025
Iteration: 99, Log-Lik: -2655.823, Max-Change: 0.00025
Iteration: 100, Log-Lik: -2655.823, Max-Change: 0.00024
Iteration: 101, Log-Lik: -2655.823, Max-Change: 0.00024
Iteration: 102, Log-Lik: -2655.823, Max-Change: 0.00024
Iteration: 103, Log-Lik: -2655.823, Max-Change: 0.00023
Iteration: 104, Log-Lik: -2655.823, Max-Change: 0.00023
Iteration: 105, Log-Lik: -2655.823, Max-Change: 0.00023
Iteration: 106, Log-Lik: -2655.823, Max-Change: 0.00022
Iteration: 107, Log-Lik: -2655.823, Max-Change: 0.00022
Iteration: 108, Log-Lik: -2655.823, Max-Change: 0.00022
Iteration: 109, Log-Lik: -2655.823, Max-Change: 0.00021
Iteration: 110, Log-Lik: -2655.823, Max-Change: 0.00021
Iteration: 111, Log-Lik: -2655.823, Max-Change: 0.00021
Iteration: 112, Log-Lik: -2655.823, Max-Change: 0.00020
Iteration: 113, Log-Lik: -2655.823, Max-Change: 0.00020
Iteration: 114, Log-Lik: -2655.823, Max-Change: 0.00020
Iteration: 115, Log-Lik: -2655.823, Max-Change: 0.00020
Iteration: 116, Log-Lik: -2655.823, Max-Change: 0.00019
Iteration: 117, Log-Lik: -2655.823, Max-Change: 0.00019
Iteration: 118, Log-Lik: -2655.823, Max-Change: 0.00019
Iteration: 119, Log-Lik: -2655.823, Max-Change: 0.00019
Iteration: 120, Log-Lik: -2655.823, Max-Change: 0.00018
Iteration: 121, Log-Lik: -2655.823, Max-Change: 0.00018
Iteration: 122, Log-Lik: -2655.823, Max-Change: 0.00018
Iteration: 123, Log-Lik: -2655.823, Max-Change: 0.00018
Iteration: 124, Log-Lik: -2655.823, Max-Change: 0.00017
Iteration: 125, Log-Lik: -2655.823, Max-Change: 0.00017
Iteration: 126, Log-Lik: -2655.823, Max-Change: 0.00017
Iteration: 127, Log-Lik: -2655.823, Max-Change: 0.00017
Iteration: 128, Log-Lik: -2655.823, Max-Change: 0.00017
Iteration: 129, Log-Lik: -2655.823, Max-Change: 0.00017
Iteration: 130, Log-Lik: -2655.823, Max-Change: 0.00016
Iteration: 131, Log-Lik: -2655.823, Max-Change: 0.00016
Iteration: 132, Log-Lik: -2655.823, Max-Change: 0.00016
Iteration: 133, Log-Lik: -2655.823, Max-Change: 0.00016
Iteration: 134, Log-Lik: -2655.823, Max-Change: 0.00015
Iteration: 135, Log-Lik: -2655.823, Max-Change: 0.00015
Iteration: 136, Log-Lik: -2655.823, Max-Change: 0.00015
Iteration: 137, Log-Lik: -2655.823, Max-Change: 0.00015
Iteration: 138, Log-Lik: -2655.823, Max-Change: 0.00015
Iteration: 139, Log-Lik: -2655.823, Max-Change: 0.00015
Iteration: 140, Log-Lik: -2655.823, Max-Change: 0.00014
Iteration: 141, Log-Lik: -2655.823, Max-Change: 0.00014
Iteration: 142, Log-Lik: -2655.823, Max-Change: 0.00014
Iteration: 143, Log-Lik: -2655.823, Max-Change: 0.00014
Iteration: 144, Log-Lik: -2655.823, Max-Change: 0.00014
Iteration: 145, Log-Lik: -2655.823, Max-Change: 0.00014
Iteration: 146, Log-Lik: -2655.823, Max-Change: 0.00013
Iteration: 147, Log-Lik: -2655.823, Max-Change: 0.00013
Iteration: 148, Log-Lik: -2655.823, Max-Change: 0.00013
Iteration: 149, Log-Lik: -2655.823, Max-Change: 0.00013
Iteration: 150, Log-Lik: -2655.823, Max-Change: 0.00013
Iteration: 151, Log-Lik: -2655.823, Max-Change: 0.00013
Iteration: 152, Log-Lik: -2655.823, Max-Change: 0.00012
Iteration: 153, Log-Lik: -2655.823, Max-Change: 0.00012
Iteration: 154, Log-Lik: -2655.823, Max-Change: 0.00012
Iteration: 155, Log-Lik: -2655.823, Max-Change: 0.00012
Iteration: 156, Log-Lik: -2655.823, Max-Change: 0.00012
Iteration: 157, Log-Lik: -2655.823, Max-Change: 0.00012
Iteration: 158, Log-Lik: -2655.823, Max-Change: 0.00012
Iteration: 159, Log-Lik: -2655.823, Max-Change: 0.00012
Iteration: 160, Log-Lik: -2655.823, Max-Change: 0.00011
Iteration: 161, Log-Lik: -2655.823, Max-Change: 0.00011
Iteration: 162, Log-Lik: -2655.823, Max-Change: 0.00011
Iteration: 163, Log-Lik: -2655.823, Max-Change: 0.00011
Iteration: 164, Log-Lik: -2655.823, Max-Change: 0.00011
Iteration: 165, Log-Lik: -2655.823, Max-Change: 0.00011
Iteration: 166, Log-Lik: -2655.823, Max-Change: 0.00011
Iteration: 167, Log-Lik: -2655.823, Max-Change: 0.00011
Iteration: 168, Log-Lik: -2655.823, Max-Change: 0.00011
Iteration: 169, Log-Lik: -2655.823, Max-Change: 0.00010
Iteration: 170, Log-Lik: -2655.823, Max-Change: 0.00010
Iteration: 171, Log-Lik: -2655.823, Max-Change: 0.00010
Iteration: 172, Log-Lik: -2655.823, Max-Change: 0.00010
Iteration: 173, Log-Lik: -2655.823, Max-Change: 0.00010
Iteration: 174, Log-Lik: -2655.823, Max-Change: 0.00010
#>
#> Calculating information matrix...
sc3 <- estfun.AllModelClass(mod3)
colSums(sc3)
#> a1.1 a3.3 d.4 a1.7 a3.9
#> 0.0018172801 0.0007522911 0.0008693077 0.0026167974 -0.0065562618
#> d.10 a1.13 a2.14 d.16 a1.19
#> 0.0010184719 0.0002582749 -0.0123565804 0.0003107030 -0.0001820340
#> a2.20 d.22 a1.25 a3.27 d.28
#> -0.0048417996 0.0020931538 -0.0005721500 -0.0060778033 -0.0028105998
vc3 <- vcov(mod3)
all.equal(crossprod(sc3), chol2inv(chol(vc3)), check.attributes = FALSE)
#> [1] TRUE
# fit a 2PL not weighting all cases equally
survey.weights <- c(rep(2, sum(LSAT7$freq) / 2), rep(1, sum(LSAT7$freq) / 2))
survey.weights <- survey.weights / sum(survey.weights) * sum(LSAT7$freq)
mod4 <- mirt(expand.table(LSAT7), 1, SE = TRUE, SE.type = "crossprod",
survey.weights = survey.weights)
#>
Iteration: 1, Log-Lik: -2990.563, Max-Change: 0.46691
Iteration: 2, Log-Lik: -2940.257, Max-Change: 0.09978
Iteration: 3, Log-Lik: -2933.905, Max-Change: 0.04361
Iteration: 4, Log-Lik: -2932.559, Max-Change: 0.03009
Iteration: 5, Log-Lik: -2932.145, Max-Change: 0.02199
Iteration: 6, Log-Lik: -2931.975, Max-Change: 0.01625
Iteration: 7, Log-Lik: -2931.829, Max-Change: 0.00684
Iteration: 8, Log-Lik: -2931.818, Max-Change: 0.00481
Iteration: 9, Log-Lik: -2931.812, Max-Change: 0.00359
Iteration: 10, Log-Lik: -2931.806, Max-Change: 0.00128
Iteration: 11, Log-Lik: -2931.806, Max-Change: 0.00088
Iteration: 12, Log-Lik: -2931.805, Max-Change: 0.00061
Iteration: 13, Log-Lik: -2931.805, Max-Change: 0.00017
Iteration: 14, Log-Lik: -2931.805, Max-Change: 0.00011
Iteration: 15, Log-Lik: -2931.805, Max-Change: 0.00011
Iteration: 16, Log-Lik: -2931.805, Max-Change: 0.00007
#>
#> Calculating information matrix...
sc4 <- estfun.AllModelClass(mod4,
weights = extract.mirt(mod4, "survey.weights"))
# get the gradient
colSums(sc4)
#> a1.1 d.2 a1.5 d.6 a1.9
#> -0.0067330450 -0.0001045753 0.0019680853 0.0007675188 0.0088929479
#> d.10 a1.13 d.14 a1.17 d.18
#> 0.0012985459 0.0016433039 -0.0008952128 -0.0071939497 -0.0031136208
# to calculate the OPG estimate of the variance-covariance matrix "by hand",
# the weights must be adjusted by taking their square root
sc4_crp <- estfun.AllModelClass(mod4,
weights = sqrt(extract.mirt(mod4, "survey.weights")))
vc4 <- vcov(mod4)
all.equal(crossprod(sc4_crp), chol2inv(chol(vc4)), check.attributes = FALSE)
#> [1] TRUE
# }