itemfit {mirt}R Documentation

Item fit statistics

Description

Computes item-fit statistics for a variety of unidimensional and multidimensional models. Poorly fitting items should be inspected with the empirical plots/tables for unidimensional models, otherwise itemGAM can be used to diagnose where the functional form of the IRT model was misspecified, or models can be refit using more flexible semi-parametric response models (e.g., itemtype = 'spline'). If the latent trait density was approximated (e.g., Davidian curves, Empirical histograms, etc) then passing use_dentype_estimate = TRUE will use the internally saved quadrature and density components (where applicable). Currently, only S-X2 statistic supported for mixture IRT models. Finally, where applicable the root mean-square error of approximation (RMSEA) is reported to help gauge the magnitude of item misfit.

Usage

itemfit(
  x,
  fit_stats = "S_X2",
  which.items = 1:extract.mirt(x, "nitems"),
  na.rm = FALSE,
  p.adjust = "none",
  group.bins = 10,
  group.size = NA,
  group.fun = mean,
  mincell = 1,
  mincell.X2 = 2,
  return.tables = FALSE,
  pv_draws = 30,
  boot = 1000,
  boot_dfapprox = 200,
  S_X2.plot = NULL,
  S_X2.plot_raw.score = TRUE,
  ETrange = c(-2, 2),
  ETpoints = 11,
  empirical.plot = NULL,
  empirical.CI = 0.95,
  empirical.poly.collapse = FALSE,
  method = "EAP",
  Theta = NULL,
  par.strip.text = list(cex = 0.7),
  par.settings = list(strip.background = list(col = "#9ECAE1"), strip.border = list(col =
    "black")),
  auto.key = list(space = "right", points = FALSE, lines = TRUE),
  ...
)

Arguments

x

a computed model object of class SingleGroupClass, MultipleGroupClass, or DiscreteClass

fit_stats

a character vector indicating which fit statistics should be computed. Supported inputs are:

  • 'S_X2' : Orlando and Thissen (2000, 2003) and Kang and Chen's (2007) signed chi-squared test (default)

  • 'Zh' : Drasgow, Levine, & Williams (1985) Zh

  • 'X2' : Bock's (1972) chi-squared method. The default inputs compute Yen's (1981) Q1 variant of the X2 statistic (i.e., uses a fixed group.bins = 10). However, Bock's group-size variable median-based method can be computed by passing group.fun = median and modifying the group.size input to the desired number of bins

  • 'G2' : McKinley & Mills (1985) G2 statistic (similar method to Q1, but with the likelihood-ratio test).

  • 'PV_Q1' : Chalmers and Ng's (2017) plausible-value variant of the Q1 statistic.

  • 'PV_Q1*' : Chalmers and Ng's (2017) plausible-value variant of the Q1 statistic that uses parametric bootstrapping to obtain a suitable empirical distribution.

  • 'X2*' : Stone's (2000) fit statistics that require parametric bootstrapping

  • 'X2*_df' : Stone's (2000) fit statistics that require parametric bootstrapping to obtain scaled versions of the X2* and degrees of freedom

  • 'infit' : Compute the infit and outfit statistics

Note that 'S_X2' and 'Zh' cannot be computed when there are missing response data (i.e., will require multiple-imputation/row-removal techniques).

which.items

an integer vector indicating which items to test for fit. Default tests all possible items

na.rm

logical; remove rows with any missing values? This is required for methods such as S-X2 because they require the "EAPsum" method from fscores

p.adjust

method to use for adjusting all p-values for each respective item fit statistic (see p.adjust for available options). Default is 'none'

group.bins

the number of bins to use for X2 and G2. For example, setting group.bins = 10 will will compute Yen's (1981) Q1 statistic when 'X2' is requested

group.size

approximate size of each group to be used in calculating the \chi^2 statistic. The default NA disables this command and instead uses the group.bins input to try and construct equally sized bins

group.fun

function used when 'X2' or 'G2' are computed. Determines the central tendency measure within each partitioned group. E.g., setting group.fun = median will obtain the median of each respective ability estimate in each subgroup (this is what was used by Bock, 1972)

mincell

the minimum expected cell size to be used in the S-X2 computations. Tables will be collapsed across items first if polytomous, and then across scores if necessary

mincell.X2

the minimum expected cell size to be used in the X2 computations. Tables will be collapsed if polytomous, however if this condition can not be met then the group block will be omitted in the computations

return.tables

logical; return tables when investigating 'X2', 'S_X2', and 'X2*'?

pv_draws

number of plausible-value draws to obtain for PV_Q1 and PV_Q1*

boot

number of parametric bootstrap samples to create for PV_Q1* and X2*

boot_dfapprox

number of parametric bootstrap samples to create for the X2*_df statistic to approximate the scaling factor for X2* as well as the scaled degrees of freedom estimates

S_X2.plot

argument input is the same as empirical.plot, however the resulting image is constructed according to the S-X2 statistic's conditional sum-score information

S_X2.plot_raw.score

logical; use the raw-score information in the plot in stead of the latent trait scale score? Default is FALSE

ETrange

rangone of integration nodes for Stone's X2* statistic

ETpoints

number of integration nodes to use for Stone's X2* statistic

empirical.plot

a single numeric value or character of the item name indicating which item to plot (via itemplot) and overlay with the empirical \theta groupings (see empirical.CI). Useful for plotting the expected bins based on the 'X2' or 'G2' method

empirical.CI

a numeric value indicating the width of the empirical confidence interval ranging between 0 and 1 (default of 0 plots not interval). For example, a 95 interval would be plotted when empirical.CI = .95. Only applicable to dichotomous items

empirical.poly.collapse

logical; collapse polytomous item categories to for expected scoring functions for empirical plots? Default is FALSE

method

type of factor score estimation method. See fscores for more detail

Theta

a matrix of factor scores for each person used for statistics that require empirical estimates. If supplied, arguments typically passed to fscores() will be ignored and these values will be used instead. Also required when estimating statistics with missing data via imputation

par.strip.text

plotting argument passed to lattice

par.settings

plotting argument passed to lattice

auto.key

plotting argument passed to lattice

...

additional arguments to be passed to fscores() and lattice

Author(s)

Phil Chalmers rphilip.chalmers@gmail.com

References

Bock, R. D. (1972). Estimating item parameters and latent ability when responses are scored in two or more nominal categories. Psychometrika, 37, 29-51.

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

Chalmers, R. P. & Ng, V. (2017). Plausible-Value Imputation Statistics for Detecting Item Misfit. Applied Psychological Measurement, 41, 372-387. doi:10.1177/0146621617692079

Drasgow, F., Levine, M. V., & Williams, E. A. (1985). Appropriateness measurement with polychotomous item response models and standardized indices. British Journal of Mathematical and Statistical Psychology, 38, 67-86.

Kang, T. & Chen, Troy, T. (2007). An investigation of the performance of the generalized S-X2 item-fit index for polytomous IRT models. ACT

McKinley, R., & Mills, C. (1985). A comparison of several goodness-of-fit statistics. Applied Psychological Measurement, 9, 49-57.

Orlando, M. & Thissen, D. (2000). Likelihood-based item fit indices for dichotomous item response theory models. Applied Psychological Measurement, 24, 50-64.

Reise, S. P. (1990). A comparison of item- and person-fit methods of assessing model-data fit in IRT. Applied Psychological Measurement, 14, 127-137.

Stone, C. A. (2000). Monte Carlo Based Null Distribution for an Alternative Goodness-of-Fit Test Statistics in IRT Models. Journal of Educational Measurement, 37, 58-75.

Wright B. D. & Masters, G. N. (1982). Rating scale analysis. MESA Press.

Yen, W. M. (1981). Using simulation results to choose a latent trait model. Applied Psychological Measurement, 5, 245-262.

See Also

personfit, itemGAM

Examples

## No test: 

P <- function(Theta){exp(Theta^2 * 1.2 - 1) / (1 + exp(Theta^2 * 1.2 - 1))}

#make some data
set.seed(1234)
a <- matrix(rlnorm(20, meanlog=0, sdlog = .1),ncol=1)
d <- matrix(rnorm(20),ncol=1)
Theta <- matrix(rnorm(2000))
items <- rep('2PL', 20)
ps <- P(Theta)
baditem <- numeric(2000)
for(i in 1:2000)
   baditem[i] <- sample(c(0,1), 1, prob = c(1-ps[i], ps[i]))
data <- cbind(simdata(a,d, 2000, items, Theta=Theta), baditem=baditem)

x <- mirt(data, 1)
raschfit <- mirt(data, 1, itemtype='Rasch')
fit <- itemfit(x)
fit
##       item    S_X2 df.S_X2 RMSEA.S_X2 p.S_X2
## 1   Item_1  16.519      15      0.007  0.348
## 2   Item_2  11.718      15      0.000  0.700
## 3   Item_3  22.835      15      0.016  0.088
## 4   Item_4  11.703      16      0.000  0.764
## 5   Item_5  15.241      15      0.003  0.434
## 6   Item_6  11.983      16      0.000  0.745
## 7   Item_7  23.912      16      0.016  0.091
## 8   Item_8  12.744      15      0.000  0.622
## 9   Item_9  16.931      15      0.008  0.323
## 10 Item_10   9.199      16      0.000  0.905
## 11 Item_11  17.630      15      0.009  0.283
## 12 Item_12  12.198      15      0.000  0.664
## 13 Item_13  17.487      15      0.009  0.291
## 14 Item_14  19.117      15      0.012  0.208
## 15 Item_15  11.542      16      0.000  0.775
## 16 Item_16  12.534      16      0.000  0.706
## 17 Item_17  29.453      15      0.022  0.014
## 18 Item_18  15.064      16      0.000  0.520
## 19 Item_19  17.125      15      0.008  0.311
## 20 Item_20  10.064      15      0.000  0.816
## 21 baditem 233.224      18      0.077  0.000
# p-value adjustment
itemfit(x, p.adjust='fdr')
##       item    S_X2 df.S_X2 RMSEA.S_X2 p.S_X2
## 1   Item_1  16.519      15      0.007  0.732
## 2   Item_2  11.718      15      0.000  0.856
## 3   Item_3  22.835      15      0.016  0.480
## 4   Item_4  11.703      16      0.000  0.856
## 5   Item_5  15.241      15      0.003  0.829
## 6   Item_6  11.983      16      0.000  0.856
## 7   Item_7  23.912      16      0.016  0.480
## 8   Item_8  12.744      15      0.000  0.856
## 9   Item_9  16.931      15      0.008  0.732
## 10 Item_10   9.199      16      0.000  0.905
## 11 Item_11  17.630      15      0.009  0.732
## 12 Item_12  12.198      15      0.000  0.856
## 13 Item_13  17.487      15      0.009  0.732
## 14 Item_14  19.117      15      0.012  0.732
## 15 Item_15  11.542      16      0.000  0.856
## 16 Item_16  12.534      16      0.000  0.856
## 17 Item_17  29.453      15      0.022  0.148
## 18 Item_18  15.064      16      0.000  0.856
## 19 Item_19  17.125      15      0.008  0.732
## 20 Item_20  10.064      15      0.000  0.856
## 21 baditem 233.224      18      0.077  0.000
# two different fit stats (with/without p-value adjustment)
itemfit(x, c('S_X2' ,'X2'), p.adjust='fdr')
##       item      X2 df.X2 RMSEA.X2  p.X2    S_X2 df.S_X2 RMSEA.S_X2 p.S_X2
## 1   Item_1  30.842     8    0.038 0.000  16.519      15      0.007  0.732
## 2   Item_2  27.970     8    0.035 0.001  11.718      15      0.000  0.856
## 3   Item_3  43.995     8    0.047 0.000  22.835      15      0.016  0.480
## 4   Item_4  33.272     8    0.040 0.000  11.703      16      0.000  0.856
## 5   Item_5  29.469     8    0.037 0.001  15.241      15      0.003  0.829
## 6   Item_6  21.325     8    0.029 0.007  11.983      16      0.000  0.856
## 7   Item_7  23.127     8    0.031 0.004  23.912      16      0.016  0.480
## 8   Item_8  25.332     8    0.033 0.002  12.744      15      0.000  0.856
## 9   Item_9  33.778     8    0.040 0.000  16.931      15      0.008  0.732
## 10 Item_10  22.972     8    0.031 0.004   9.199      16      0.000  0.905
## 11 Item_11  27.300     8    0.035 0.001  17.630      15      0.009  0.732
## 12 Item_12  23.256     8    0.031 0.004  12.198      15      0.000  0.856
## 13 Item_13  31.523     8    0.038 0.000  17.487      15      0.009  0.732
## 14 Item_14  27.924     8    0.035 0.001  19.117      15      0.012  0.732
## 15 Item_15  18.462     8    0.026 0.020  11.542      16      0.000  0.856
## 16 Item_16  25.057     8    0.033 0.002  12.534      16      0.000  0.856
## 17 Item_17  14.828     8    0.021 0.063  29.453      15      0.022  0.148
## 18 Item_18  17.676     8    0.025 0.025  15.064      16      0.000  0.856
## 19 Item_19  32.585     8    0.039 0.000  17.125      15      0.008  0.732
## 20 Item_20  37.207     8    0.043 0.000  10.064      15      0.000  0.856
## 21 baditem 228.367     8    0.117 0.000 233.224      18      0.077  0.000
itemfit(x, c('S_X2' ,'X2'))
##       item      X2 df.X2 RMSEA.X2  p.X2    S_X2 df.S_X2 RMSEA.S_X2 p.S_X2
## 1   Item_1  30.842     8    0.038 0.000  16.519      15      0.007  0.348
## 2   Item_2  27.970     8    0.035 0.000  11.718      15      0.000  0.700
## 3   Item_3  43.995     8    0.047 0.000  22.835      15      0.016  0.088
## 4   Item_4  33.272     8    0.040 0.000  11.703      16      0.000  0.764
## 5   Item_5  29.469     8    0.037 0.000  15.241      15      0.003  0.434
## 6   Item_6  21.325     8    0.029 0.006  11.983      16      0.000  0.745
## 7   Item_7  23.127     8    0.031 0.003  23.912      16      0.016  0.091
## 8   Item_8  25.332     8    0.033 0.001  12.744      15      0.000  0.622
## 9   Item_9  33.778     8    0.040 0.000  16.931      15      0.008  0.323
## 10 Item_10  22.972     8    0.031 0.003   9.199      16      0.000  0.905
## 11 Item_11  27.300     8    0.035 0.001  17.630      15      0.009  0.283
## 12 Item_12  23.256     8    0.031 0.003  12.198      15      0.000  0.664
## 13 Item_13  31.523     8    0.038 0.000  17.487      15      0.009  0.291
## 14 Item_14  27.924     8    0.035 0.000  19.117      15      0.012  0.208
## 15 Item_15  18.462     8    0.026 0.018  11.542      16      0.000  0.775
## 16 Item_16  25.057     8    0.033 0.002  12.534      16      0.000  0.706
## 17 Item_17  14.828     8    0.021 0.063  29.453      15      0.022  0.014
## 18 Item_18  17.676     8    0.025 0.024  15.064      16      0.000  0.520
## 19 Item_19  32.585     8    0.039 0.000  17.125      15      0.008  0.311
## 20 Item_20  37.207     8    0.043 0.000  10.064      15      0.000  0.816
## 21 baditem 228.367     8    0.117 0.000 233.224      18      0.077  0.000
# Conditional sum-score plot from S-X2 information
itemfit(x, S_X2.plot = 1) # good fit

plot of chunk unnamed-chunk-1

itemfit(x, S_X2.plot = 2) # good fit

plot of chunk unnamed-chunk-1

itemfit(x, S_X2.plot = 21) # bad fit

plot of chunk unnamed-chunk-1

itemfit(x, 'X2') # just X2
##       item      X2 df.X2 RMSEA.X2  p.X2
## 1   Item_1  30.842     8    0.038 0.000
## 2   Item_2  27.970     8    0.035 0.000
## 3   Item_3  43.995     8    0.047 0.000
## 4   Item_4  33.272     8    0.040 0.000
## 5   Item_5  29.469     8    0.037 0.000
## 6   Item_6  21.325     8    0.029 0.006
## 7   Item_7  23.127     8    0.031 0.003
## 8   Item_8  25.332     8    0.033 0.001
## 9   Item_9  33.778     8    0.040 0.000
## 10 Item_10  22.972     8    0.031 0.003
## 11 Item_11  27.300     8    0.035 0.001
## 12 Item_12  23.256     8    0.031 0.003
## 13 Item_13  31.523     8    0.038 0.000
## 14 Item_14  27.924     8    0.035 0.000
## 15 Item_15  18.462     8    0.026 0.018
## 16 Item_16  25.057     8    0.033 0.002
## 17 Item_17  14.828     8    0.021 0.063
## 18 Item_18  17.676     8    0.025 0.024
## 19 Item_19  32.585     8    0.039 0.000
## 20 Item_20  37.207     8    0.043 0.000
## 21 baditem 228.367     8    0.117 0.000
itemfit(x, 'X2', method = 'ML') # X2 with maximum-likelihood estimates for traits
## Warning: The following factor score estimates failed to converge successfully:
##     311,315,352,518,677,748,909,927,1081,1243,1277,1305,1415,1480,1620,1893
##       item      X2 df.X2 RMSEA.X2  p.X2
## 1   Item_1  35.941     8    0.042 0.000
## 2   Item_2  53.226     8    0.053 0.000
## 3   Item_3  47.010     8    0.049 0.000
## 4   Item_4  85.852     8    0.070 0.000
## 5   Item_5  85.280     8    0.070 0.000
## 6   Item_6   8.632     8    0.006 0.374
## 7   Item_7  57.623     8    0.056 0.000
## 8   Item_8  42.952     8    0.047 0.000
## 9   Item_9  55.180     8    0.054 0.000
## 10 Item_10  32.456     8    0.039 0.000
## 11 Item_11 131.613     8    0.088 0.000
## 12 Item_12  50.094     8    0.051 0.000
## 13 Item_13  55.846     8    0.055 0.000
## 14 Item_14  18.717     8    0.026 0.016
## 15 Item_15  12.402     8    0.017 0.134
## 16 Item_16  38.229     8    0.043 0.000
## 17 Item_17   4.413     8    0.000 0.818
## 18 Item_18  16.165     8    0.023 0.040
## 19 Item_19  14.190     8    0.020 0.077
## 20 Item_20  21.215     8    0.029 0.007
## 21 baditem 227.191     8    0.117 0.000
itemfit(x, group.bins=15, empirical.plot = 1, method = 'ML') #empirical item plot with 15 points
## Warning: The following factor score estimates failed to converge successfully:
##     311,315,352,518,677,748,909,927,1081,1243,1277,1305,1415,1480,1620,1893

plot of chunk unnamed-chunk-1

itemfit(x, group.bins=15, empirical.plot = 21, method = 'ML')
## Warning: The following factor score estimates failed to converge successfully:
##     311,315,352,518,677,748,909,927,1081,1243,1277,1305,1415,1480,1620,1893

plot of chunk unnamed-chunk-1

# PV and X2* statistics (parametric bootstrap stats not run to save time)
itemfit(x, 'PV_Q1')
##       item   PV_Q1 df.PV_Q1 RMSEA.PV_Q1 p.PV_Q1
## 1   Item_1   9.145        8       0.008   0.330
## 2   Item_2   9.343        8       0.009   0.314
## 3   Item_3   7.652        8       0.000   0.468
## 4   Item_4   9.478        8       0.010   0.304
## 5   Item_5   7.549        8       0.000   0.479
## 6   Item_6   7.196        8       0.000   0.516
## 7   Item_7   9.681        8       0.010   0.288
## 8   Item_8   7.312        8       0.000   0.503
## 9   Item_9   9.662        8       0.010   0.290
## 10 Item_10   7.235        8       0.000   0.511
## 11 Item_11   9.461        8       0.010   0.305
## 12 Item_12   8.930        8       0.008   0.348
## 13 Item_13   8.320        8       0.004   0.403
## 14 Item_14   8.655        8       0.006   0.372
## 15 Item_15   8.308        8       0.004   0.404
## 16 Item_16   9.187        8       0.009   0.327
## 17 Item_17   8.175        8       0.003   0.417
## 18 Item_18   7.139        8       0.000   0.522
## 19 Item_19   8.087        8       0.002   0.425
## 20 Item_20   7.985        8       0.000   0.435
## 21 baditem 123.641        8       0.085   0.000
if(interactive()) mirtCluster() # improve speed of bootstrap samples by running in parallel
# itemfit(x, 'PV_Q1*')
# itemfit(x, 'X2*') # Stone's 1993 statistic
# itemfit(x, 'X2*_df') # Stone's 2000 scaled statistic with df estimate

# empirical tables for X2 statistic
tabs <- itemfit(x, 'X2', return.tables=TRUE, which.items = 1)
tabs
## $`theta = -1.4531`
##       Observed  Expected z.Residual
## cat_0      183 158.63869   1.934176
## cat_1       17  41.36131  -3.787943
## 
## $`theta = -0.9416`
##       Observed  Expected z.Residual
## cat_0      149 138.43172  0.8982277
## cat_1       51  61.56828 -1.3468702
## 
## $`theta = -0.6475`
##       Observed  Expected z.Residual
## cat_0      132 124.64146  0.6591135
## cat_1       68  75.35854 -0.8476670
## 
## $`theta = -0.3921`
##       Observed  Expected  z.Residual
## cat_0      112 111.77447  0.02133235
## cat_1       88  88.22553 -0.02401114
## 
## $`theta = -0.1393`
##       Observed  Expected z.Residual
## cat_0       88  98.63125  -1.070476
## cat_1      112 101.36875   1.055923
## 
## $`theta = 0.0936`
##       Observed Expected  z.Residual
## cat_0       86  86.5533 -0.05947283
## cat_1      114 113.4467  0.05194748
## 
## $`theta = 0.346`
##       Observed  Expected z.Residual
## cat_0       61  73.91477  -1.502177
## cat_1      139 126.08523   1.150150
## 
## $`theta = 0.6087`
##       Observed  Expected z.Residual
## cat_0       54  61.64828 -0.9740998
## cat_1      146 138.35172  0.6502370
## 
## $`theta = 0.9646`
##       Observed Expected z.Residual
## cat_0       41  47.0127 -0.8769235
## cat_1      159 152.9873  0.4861179
## 
## $`theta = 1.5621`
##       Observed  Expected z.Residual
## cat_0       24  28.27768 -0.8044264
## cat_1      176 171.72232  0.3264336
#infit/outfit statistics. method='ML' agrees better with eRm package
itemfit(raschfit, 'infit', method = 'ML') #infit and outfit stats
##       item outfit z.outfit infit z.infit
## 1   Item_1  0.919   -2.945 0.951  -2.699
## 2   Item_2  0.962   -1.281 0.960  -2.010
## 3   Item_3  0.876   -4.455 0.918  -4.332
## 4   Item_4  0.998   -0.049 1.009   0.495
## 5   Item_5  0.982   -0.523 0.974  -1.227
## 6   Item_6  0.890   -2.233 0.950  -1.692
## 7   Item_7  1.008    0.259 1.003   0.171
## 8   Item_8  0.933   -1.743 0.961  -1.631
## 9   Item_9  0.958   -1.519 0.964  -1.999
## 10 Item_10  1.011    0.303 1.013   0.534
## 11 Item_11  0.898   -2.300 0.939  -2.531
## 12 Item_12  0.988   -0.383 1.012   0.607
## 13 Item_13  0.991   -0.263 1.002   0.093
## 14 Item_14  0.973   -0.841 0.974  -1.256
## 15 Item_15  0.947   -0.943 0.993  -0.210
## 16 Item_16  0.988   -0.271 0.985  -0.546
## 17 Item_17  0.878   -1.532 0.960  -0.872
## 18 Item_18  0.961   -0.759 0.978  -0.742
## 19 Item_19  0.943   -2.060 0.974  -1.352
## 20 Item_20  0.868   -4.736 0.911  -4.687
## 21 baditem  1.513   16.123 1.338  16.509
#same as above, but inputting ML estimates instead (saves time for re-use)
Theta <- fscores(raschfit, method = 'ML')
itemfit(raschfit, 'infit', Theta=Theta)
##       item outfit z.outfit infit z.infit
## 1   Item_1  0.919   -2.945 0.951  -2.699
## 2   Item_2  0.962   -1.281 0.960  -2.010
## 3   Item_3  0.876   -4.455 0.918  -4.332
## 4   Item_4  0.998   -0.049 1.009   0.495
## 5   Item_5  0.982   -0.523 0.974  -1.227
## 6   Item_6  0.890   -2.233 0.950  -1.692
## 7   Item_7  1.008    0.259 1.003   0.171
## 8   Item_8  0.933   -1.743 0.961  -1.631
## 9   Item_9  0.958   -1.519 0.964  -1.999
## 10 Item_10  1.011    0.303 1.013   0.534
## 11 Item_11  0.898   -2.300 0.939  -2.531
## 12 Item_12  0.988   -0.383 1.012   0.607
## 13 Item_13  0.991   -0.263 1.002   0.093
## 14 Item_14  0.973   -0.841 0.974  -1.256
## 15 Item_15  0.947   -0.943 0.993  -0.210
## 16 Item_16  0.988   -0.271 0.985  -0.546
## 17 Item_17  0.878   -1.532 0.960  -0.872
## 18 Item_18  0.961   -0.759 0.978  -0.742
## 19 Item_19  0.943   -2.060 0.974  -1.352
## 20 Item_20  0.868   -4.736 0.911  -4.687
## 21 baditem  1.513   16.123 1.338  16.509
itemfit(raschfit, empirical.plot=1, Theta=Theta)

plot of chunk unnamed-chunk-1

itemfit(raschfit, 'X2', return.tables=TRUE, Theta=Theta, which.items=1)
## $`theta = -1.7718`
##       Observed  Expected z.Residual
## cat_0      177 166.44926  0.8177906
## cat_1       23  33.55074 -1.8215117
## 
## $`theta = -1.0782`
##       Observed  Expected z.Residual
## cat_0      150 142.51602  0.6269036
## cat_1       50  57.48398 -0.9870955
## 
## $`theta = -0.7497`
##       Observed  Expected z.Residual
## cat_0      132 128.19072  0.3364454
## cat_1       68  71.80928 -0.4495237
## 
## $`theta = -0.4577`
##       Observed Expected z.Residual
## cat_0      118 114.2782  0.3481537
## cat_1       82  85.7218 -0.4019824
## 
## $`theta = -0.193`
##       Observed  Expected z.Residual
## cat_0       86 101.13957  -1.505404
## cat_1      114  98.86043   1.522658
## 
## $`theta = 0.0765`
##       Observed Expected z.Residual
## cat_0       75  87.7275  -1.358862
## cat_1      125 112.2725   1.201175
## 
## $`theta = 0.3374`
##       Observed  Expected z.Residual
## cat_0       72  75.15333 -0.3637435
## cat_1      128 124.84667  0.2822155
## 
## $`theta = 0.6728`
##       Observed  Expected z.Residual
## cat_0       54  60.18187 -0.7968690
## cat_1      146 139.81813  0.5228029
## 
## $`theta = 1.0787`
##       Observed  Expected  z.Residual
## cat_0       44  44.57924 -0.08675380
## cat_1      156 155.42076  0.04646226
## 
## $`theta = 1.9249`
##       Observed  Expected   z.Residual
## cat_0       22  21.91506  0.018144153
## cat_1      178 178.08494 -0.006364942
# fit a new more flexible model for the mis-fitting item
itemtype <- c(rep('2PL', 20), 'spline')
x2 <- mirt(data, 1, itemtype=itemtype)
## EM cycles terminated after 500 iterations.
itemfit(x2)
##       item   S_X2 df.S_X2 RMSEA.S_X2 p.S_X2
## 1   Item_1 13.109      15      0.000  0.594
## 2   Item_2 13.513      15      0.000  0.563
## 3   Item_3 21.887      15      0.015  0.111
## 4   Item_4  9.894      15      0.000  0.826
## 5   Item_5 16.248      15      0.006  0.366
## 6   Item_6 10.218      16      0.000  0.855
## 7   Item_7 18.279      15      0.010  0.248
## 8   Item_8 13.587      16      0.000  0.629
## 9   Item_9 13.485      15      0.000  0.565
## 10 Item_10 10.569      16      0.000  0.835
## 11 Item_11 16.325      15      0.007  0.361
## 12 Item_12  9.663      15      0.000  0.840
## 13 Item_13 19.394      16      0.010  0.249
## 14 Item_14 16.357      15      0.007  0.359
## 15 Item_15  9.410      16      0.000  0.896
## 16 Item_16 13.578      16      0.000  0.630
## 17 Item_17 29.945      16      0.021  0.018
## 18 Item_18 15.058      16      0.000  0.520
## 19 Item_19 15.663      15      0.005  0.405
## 20 Item_20  9.333      15      0.000  0.859
## 21 baditem 11.473      13      0.000  0.571
itemplot(x2, 21)

plot of chunk unnamed-chunk-1

anova(x, x2)
##         AIC    SABIC       HQ      BIC    logLik     X2 df p
## x  49477.85 49579.65 49564.23 49713.09 -24696.93            
## x2 49214.97 49321.62 49305.46 49461.41 -24563.49 266.88  2 0
#------------------------------------------------------------

#similar example to Kang and Chen 2007
a <- matrix(c(.8,.4,.7, .8, .4, .7, 1, 1, 1, 1))
d <- matrix(rep(c(2.0,0.0,-1,-1.5),10), ncol=4, byrow=TRUE)
dat <- simdata(a,d,2000, itemtype = rep('graded', 10))
head(dat)
##      Item_1 Item_2 Item_3 Item_4 Item_5 Item_6 Item_7 Item_8 Item_9 Item_10
## [1,]      0      3      0      2      1      0      0      0      4       0
## [2,]      2      0      4      2      1      1      3      3      2       3
## [3,]      2      2      0      3      0      2      2      3      2       1
## [4,]      2      1      3      1      0      4      4      1      2       1
## [5,]      1      2      3      4      1      0      1      1      0       1
## [6,]      2      2      2      2      1      2      4      1      4       2
mod <- mirt(dat, 1)
itemfit(mod)
##       item    S_X2 df.S_X2 RMSEA.S_X2 p.S_X2
## 1   Item_1  93.899      99      0.000  0.626
## 2   Item_2 124.960     107      0.009  0.113
## 3   Item_3  94.334     103      0.000  0.717
## 4   Item_4  99.476     100      0.000  0.496
## 5   Item_5  95.050     107      0.000  0.789
## 6   Item_6 104.562     103      0.003  0.439
## 7   Item_7  96.436      98      0.000  0.526
## 8   Item_8  82.266      95      0.000  0.821
## 9   Item_9  92.077      95      0.000  0.566
## 10 Item_10 115.494      96      0.010  0.086
itemfit(mod, 'X2') # less useful given inflated Type I error rates
##       item      X2 df.X2 RMSEA.X2  p.X2
## 1   Item_1 100.685    35    0.031 0.000
## 2   Item_2  44.310    35    0.012 0.135
## 3   Item_3  75.078    35    0.024 0.000
## 4   Item_4 100.085    35    0.031 0.000
## 5   Item_5  43.830    35    0.011 0.145
## 6   Item_6  80.692    35    0.026 0.000
## 7   Item_7 127.791    35    0.036 0.000
## 8   Item_8 156.723    35    0.042 0.000
## 9   Item_9 155.003    35    0.041 0.000
## 10 Item_10 141.590    35    0.039 0.000
itemfit(mod, empirical.plot = 1)

plot of chunk unnamed-chunk-1

itemfit(mod, empirical.plot = 1, empirical.poly.collapse=TRUE)

plot of chunk unnamed-chunk-1

# collapsed tables (see mincell.X2) for X2 and G2
itemfit(mod, 'X2', return.tables = TRUE, which.items = 1)
## $`theta = -1.4209`
##       Observed  Expected z.Residual
## cat_0       85 55.318942  3.9906389
## cat_1       86 94.701446 -0.8941556
## cat_2       23 28.143472 -0.9695441
## cat_3        1  7.827705 -2.4403805
## cat_4        5 14.008434 -2.4068804
## 
## $`theta = -0.8835`
##       Observed Expected z.Residual
## cat_0       44 39.95035  0.6407034
## cat_1      104 92.47230  1.1987731
## cat_2       34 35.96463 -0.3276000
## cat_3       10 10.92542 -0.2799763
## cat_4        8 20.68730 -2.7894411
## 
## $`theta = -0.563`
##       Observed Expected z.Residual
## cat_0       39 32.43609  1.1525205
## cat_1       94 88.18776  0.6189264
## cat_2       30 40.39554 -1.6356118
## cat_3       17 13.08011  1.0838460
## cat_4       20 25.90050 -1.1594035
## 
## $`theta = -0.3083`
##       Observed Expected z.Residual
## cat_0       35 27.31090  1.4713222
## cat_1       79 83.46536 -0.4887684
## cat_2       46 43.50774  0.3778421
## cat_3       14 14.90778 -0.2351110
## cat_4       26 30.80823 -0.8662673
## 
## $`theta = -0.0807`
##       Observed Expected z.Residual
## cat_0       17 23.32415 -1.3094810
## cat_1       90 78.46291  1.3024593
## cat_2       43 45.81785 -0.4162944
## cat_3       20 16.58020  0.8398582
## cat_4       30 35.81489 -0.9716503
## 
## $`theta = 0.1187`
##       Observed Expected   z.Residual
## cat_0       18 20.25693 -0.501454266
## cat_1       72 73.62776 -0.189700444
## cat_2       53 47.37701  0.816926990
## cat_3       18 18.03394 -0.007992367
## cat_4       39 40.70436 -0.267141305
## 
## $`theta = 0.321`
##       Observed Expected z.Residual
## cat_0       11 17.51585 -1.5568808
## cat_1       74 68.42858  0.6735147
## cat_2       47 48.44462 -0.2075543
## cat_3       15 19.45455 -1.0099339
## cat_4       53 46.15640  1.0073225
## 
## $`theta = 0.5646`
##       Observed Expected z.Residual
## cat_0        6 14.66259 -2.2622598
## cat_1       47 61.96236 -1.9007986
## cat_2       58 48.97640  1.2893969
## cat_3       22 21.02536  0.2125546
## cat_4       67 53.37329  1.8652157
## 
## $`theta = 0.8662`
##       Observed Expected  z.Residual
## cat_0        8 11.72523 -1.08790886
## cat_1       53 53.94787 -0.12905058
## cat_2       45 48.45154 -0.49586039
## cat_3       23 22.63571  0.07656825
## cat_4       71 63.23965  0.97585804
## 
## $`theta = 1.3871`
##       Observed  Expected z.Residual
## cat_0        3  7.913029 -1.7465378
## cat_1       21 40.961089 -3.1188787
## cat_2       39 44.690593 -0.8512350
## cat_3       26 24.147525  0.3769781
## cat_4      111 82.287764  3.1651871
mod2 <- mirt(dat, 1, 'Rasch')
itemfit(mod2, 'infit', method = 'ML')
##       item outfit z.outfit infit z.infit
## 1   Item_1  0.914   -3.080 0.925  -3.065
## 2   Item_2  1.122    4.063 1.093   3.524
## 3   Item_3  0.990   -0.324 0.979  -0.828
## 4   Item_4  0.943   -2.021 0.941  -2.410
## 5   Item_5  1.073    2.459 1.056   2.112
## 6   Item_6  0.969   -1.098 0.965  -1.381
## 7   Item_7  0.881   -4.353 0.894  -4.413
## 8   Item_8  0.842   -5.779 0.864  -5.738
## 9   Item_9  0.867   -4.894 0.869  -5.520
## 10 Item_10  0.867   -4.825 0.886  -4.711
# massive list of tables for S-X2
tables <- itemfit(mod, return.tables = TRUE)

#observed and expected total score patterns for item 1 (post collapsing)
tables$O[[1]]
##     0  1  2  3  4
## 4   3  3  0  0  0
## 5   4  7  0  0  0
## 6  15  3  2  0  0
## 7  10 18  5  0  0
## 8  14 11  3  0  0
## 9  14 32  5  1  1
## 10 18 34 11  2  2
## 11 22 28 15  3  3
## 12 24 40 13  1  2
## 13 18 39 17  9  2
## 14 19 44 18  3 13
## 15 18 51 23 13  9
## 16 16 48 30  8 10
## 17 13 52 23 12 23
## 18  8 44 24 13 20
## 19  8 44 25 10 23
## 20 16 43 28 11 19
## 21  7 29 30  8 32
## 22  2 36 30  7 33
## 23  6 22 15 10 33
## 24  3 27 23  7 30
## 25  3 18 14  7 21
## 26  3 15  9 10 24
## 27  0  8 13  8 17
## 28  1  8 16  5 30
## 29  9 11  4 25  0
## 30  5  7  3 15  0
## 31  2  5  4 11  0
## 32  2  2  1 10  0
## 33  0  1 11  0  0
## 34  1  3  0  0  0
## 35  4  8  0  0  0
tables$E[[1]]
##            [,1]      [,2]      [,3]      [,4]      [,5]
##  [1,]  3.918319  2.081681        NA        NA        NA
##  [2,]  6.149385  4.850615        NA        NA        NA
##  [3,]  9.790108  8.811645  1.398247        NA        NA
##  [4,] 14.166358 15.598449  3.235193        NA        NA
##  [5,] 10.565592 13.809121  3.625286        NA        NA
##  [6,] 17.619194 26.724159  6.379443  1.145497  1.131706
##  [7,] 19.653375 34.024048  9.338550  1.878077  2.105950
##  [8,] 18.391936 35.887947 11.163374  2.473284  3.083458
##  [9,] 18.311048 39.853726 13.905549  3.354018  4.575659
## [10,] 17.200670 41.378213 16.061883  4.183872  6.175362
## [11,] 17.357395 45.806904 19.639643  5.491783  8.704275
## [12,] 18.030005 51.892302 24.430514  7.295867 12.351312
## [13,] 15.644437 48.847779 25.142954  7.986595 14.378236
## [14,] 15.162220 51.104822 28.653260  9.655383 18.424314
## [15,] 11.841855 42.914514 26.115721  9.317322 18.810588
## [16,] 10.509753 40.826502 26.891436 10.138380 21.633929
## [17,]  9.808086 40.713579 28.971704 11.527946 25.978686
## [18,]  7.775829 34.393940 26.389101 11.078289 26.362841
## [19,]  6.905168 32.497640 26.834662 11.880618 29.881911
## [20,]  4.769487 23.851027 21.182620  9.886852 26.310014
## [21,]  4.308005 22.849919 21.816342 10.743154 30.282581
## [22,]  2.584337 14.542330 14.910553  7.754323 23.208457
## [23,]  2.124578 12.697321 13.991945  7.687538 24.498618
## [24,]  1.348138  8.548585 10.141406  5.899082 20.062788
## [25,]  1.460285  9.857127 12.582420  7.772226 28.327941
## [26,]  7.996846  9.684061  6.357311 24.961781        NA
## [27,]  4.164540  5.525401  3.873754 16.436305        NA
## [28,]  2.556865  3.709920  2.799879 12.933336        NA
## [29,]  1.420711  2.289320  1.856324  9.433645        NA
## [30,]  2.516859  1.438434  8.044707        NA        NA
## [31,]  1.144051  2.855949        NA        NA        NA
## [32,]  2.567132  9.432868        NA        NA        NA
# can also select specific items
# itemfit(mod, return.tables = TRUE, which.items=1)

# fit stats with missing data (run in parallel using all cores)
dat[sample(1:prod(dim(dat)), 100)] <- NA
raschfit <- mirt(dat, 1, itemtype='Rasch')

# use only valid data by removing rows with missing terms
itemfit(raschfit, c('S_X2', 'infit'), na.rm = TRUE)
## Sample size after row-wise response data removal: 1902
##       item outfit z.outfit infit z.infit    S_X2 df.S_X2 RMSEA.S_X2 p.S_X2
## 1   Item_1  0.886   -4.564 0.898  -4.329 100.645      99      0.003  0.435
## 2   Item_2  1.002    0.066 1.004   0.154 194.402     100      0.022  0.000
## 3   Item_3  0.929   -2.725 0.935  -2.666 109.765     100      0.007  0.237
## 4   Item_4  0.909   -3.639 0.915  -3.611 104.507      99      0.005  0.333
## 5   Item_5  0.977   -0.818 0.984  -0.613 148.139     101      0.016  0.002
## 6   Item_6  0.923   -3.051 0.930  -2.918  93.554      99      0.000  0.636
## 7   Item_7  0.871   -5.252 0.885  -4.986  92.260      99      0.000  0.671
## 8   Item_8  0.829   -7.062 0.846  -6.790  98.170      99      0.000  0.505
## 9   Item_9  0.855   -5.983 0.863  -6.007 121.479      99      0.011  0.062
## 10 Item_10  0.859   -5.631 0.874  -5.369 115.269      99      0.009  0.126
# note that X2, G2, PV-Q1, and X2* do not require complete datasets
thetas <- fscores(raschfit, method = 'ML') # save for faster computations
itemfit(raschfit, c('X2', 'G2'), Theta=thetas)
##       item      X2 df.X2 RMSEA.X2  p.X2      G2 df.G2 RMSEA.G2  p.G2
## 1   Item_1  37.074    36    0.004 0.419  38.322    36    0.006 0.365
## 2   Item_2 120.017    36    0.034 0.000 102.400    36    0.030 0.000
## 3   Item_3  28.885    36    0.000 0.794  27.393    36    0.000 0.848
## 4   Item_4  57.451    36    0.017 0.013  58.888    36    0.018 0.009
## 5   Item_5  61.467    36    0.019 0.005  57.357    36    0.017 0.013
## 6   Item_6  33.858    36    0.000 0.571  34.153    36    0.000 0.557
## 7   Item_7  43.905    36    0.010 0.171  47.054    36    0.012 0.103
## 8   Item_8  65.095    36    0.020 0.002  74.378    34    0.024 0.000
## 9   Item_9  70.902    36    0.022 0.000  77.084    36    0.024 0.000
## 10 Item_10  43.057    36    0.010 0.195  47.083    36    0.012 0.102
itemfit(raschfit, empirical.plot=1, Theta=thetas)

plot of chunk unnamed-chunk-1

itemfit(raschfit, 'X2', return.tables=TRUE, which.items=1, Theta=thetas)
## $`theta = -0.9112`
##       Observed  Expected  z.Residual
## cat_0       74 76.474292 -0.28293927
## cat_1       95 94.313668  0.07067191
## cat_2       25 22.688681  0.48523846
## cat_3        3  3.415978 -0.22506753
## cat_4        3  3.107381 -0.06091557
## 
## $`theta = -0.4759`
##       Observed  Expected z.Residual
## cat_0       56 49.364268  0.9444577
## cat_1       93 94.081673 -0.1115176
## cat_2       37 34.976215  0.3421984
## cat_3        7  8.137889 -0.3988817
## cat_4        5 11.439955 -1.9040164
## 
## $`theta = -0.2792`
##       Observed Expected  z.Residual
## cat_0       37 38.24559 -0.20141078
## cat_1       88 88.74113 -0.07867452
## cat_2       36 40.16466 -0.65713925
## cat_3       16 11.37717  1.37053576
## cat_4       21 19.47145  0.34640246
## 
## $`theta = -0.1503`
##       Observed Expected z.Residual
## cat_0       26 31.48316 -0.9772193
## cat_1       83 83.10062 -0.0110374
## cat_2       48 42.78638  0.7970516
## cat_3       17 13.78726  0.8652389
## cat_4       24 26.84257 -0.5486554
## 
## $`theta = -0.0417`
##       Observed Expected z.Residual
## cat_0       20 26.21235 -1.2133965
## cat_1       87 77.12301  1.1246901
## cat_2       38 44.26265 -0.9413249
## cat_3       22 15.89872  1.5301712
## cat_4       31 34.50328 -0.5964093
## 
## $`theta = 0.0656`
##       Observed Expected z.Residual
## cat_0       20 21.46057 -0.3152841
## cat_1       80 70.29090  1.1580562
## cat_2       45 44.90889  0.0135956
## cat_3       16 17.95712 -0.4618488
## cat_4       37 43.38252 -0.9690245
## 
## $`theta = 0.1654`
##       Observed Expected z.Residual
## cat_0       13 17.49621 -1.0749152
## cat_1       53 63.32206 -1.2971463
## cat_2       55 44.70352  1.5399906
## cat_3       16 19.75147 -0.8441163
## cat_4       61 52.72674  1.1393606
## 
## $`theta = 0.2723`
##       Observed Expected  z.Residual
## cat_0        9 13.77876 -1.28738966
## cat_1       62 55.49585  0.87309327
## cat_2       48 43.59998  0.66636370
## cat_3       16 21.43795 -1.17447529
## cat_4       63 63.68746 -0.08614318
## 
## $`theta = 0.414`
##       Observed  Expected z.Residual
## cat_0        7  9.720901 -0.8726891
## cat_1       48 45.112049  0.4299753
## cat_2       42 40.837018  0.1819893
## cat_3       29 23.135915  1.2191492
## cat_4       72 79.194115 -0.8084086
## 
## $`theta = 0.6937`
##       Observed   Expected  z.Residual
## cat_0        2   4.472742 -1.16920829
## cat_1       26  27.456381 -0.27794145
## cat_2       40  32.876697  1.24233106
## cat_3       22  24.637932 -0.53144891
## cat_4      111 111.556248 -0.05266492
## End(No test)

[Package mirt version 1.40 Index]