Diagnostic tests

Refer to the Rmd source code to see how to adapt this template to your project.

Pair-wise local dependence test

spec <- list()
spec[1:6] <- rpf.grm(factors=2)
gen.param <- sapply(spec, rpf.rparam)
colnames(gen.param) <- paste("i", 1:ncol(gen.param), sep="")
gen.param[2,] <- c(0,0,.5,.5,1,1)

resp <- rpf.sample(1000, spec, gen.param)

# hide latent factor that we don't know about
tspec <- list()
tspec[1:length(spec)] <- rpf.grm(factors=1)

grp <- list(spec=tspec, param=gen.param[-2,], mean=c(0), cov=diag(1), data=resp)

ChenThissen1997(grp)
## Chen & Thissen (1997) local dependence test
##   Magnitudes larger than abs(log(.01))=4.6 are significant at the p=.01 level
##   A positive (negative) sign indicates more (less) observed correlation than expected
## 
##       i1    i2    i3    i4    i5 i6
## i1    NA    NA    NA    NA    NA NA
## i2  2.83    NA    NA    NA    NA NA
## i3  0.73 -2.73    NA    NA    NA NA
## i4 -5.64 -3.89 -1.54    NA    NA NA
## i5 -7.03 -9.34 -3.54  4.82    NA NA
## i6 -3.01 -4.87 -2.21 -4.19 -4.46 NA

Sum-score item fit test

(got <- SitemFit(grp))
## Orlando & Thissen (2000) sum-score based item fit test
##   Magnitudes larger than abs(log(.01))=4.6 are significant at the p=.01 level
## 
## i1 : n = 1000, S-X2(  4) =   5.68, log(p) = -1.5
## i2 : n = 1000, S-X2(  4) =   5.69, log(p) = -1.5
## i3 : n = 1000, S-X2(  1) =   0.00, log(p) = 0
## i4 : n = 1000, S-X2(  4) =   2.64, log(p) = -0.48
## i5 : n = 1000, S-X2(  4) =   7.22, log(p) = -2.08
## i6 : n = 1000, S-X2(  4) =   4.85, log(p) = -1.19

Who can resist plotting these tables?

plot of chunk unnamed-chunk-4 plot of chunk unnamed-chunk-4 plot of chunk unnamed-chunk-4 plot of chunk unnamed-chunk-4 plot of chunk unnamed-chunk-4 plot of chunk unnamed-chunk-4

Sum-score EAP table

(got <- sumScoreEAP(grp))
##           p      a1    se1   cov1
## 0 6.851e-01 -0.3300 0.8432 0.7110
## 1 2.179e-01  0.3921 0.8342 0.6960
## 2 6.493e-02  1.2267 0.6515 0.4245
## 3 2.360e-02  1.7727 0.5691 0.3238
## 4 7.348e-03  2.2097 0.5783 0.3344
## 5 1.153e-03  2.5243 0.5745 0.3300
## 6 5.681e-06  2.7262 0.5992 0.3591
## 
## Latent distribution fit test (n=1000):
##   RMS log(p) = -3.14
##   Pearson X^2(  5) = 7.59, log(p) = -1.71

plot of chunk unnamed-chunk-6

Rasch residual-based infit/outfit

  data(science)
  spec <- list()
  spec[1:25] <- rpf.nrm(outcomes=3, T.c = lower.tri(diag(2),TRUE) * -1)
  param <- rbind(a=1, alf1=1, alf2=0,
        gam1=sfif$MEASURE + sfsf[sfsf$CATEGORY==1,"Rasch.Andrich.threshold.MEASURE"],
        gam2=sfif$MEASURE + sfsf[sfsf$CATEGORY==2,"Rasch.Andrich.threshold.MEASURE"])
  colnames(param) <- sfif$NAME
  iorder <- match(sfif$NAME, colnames(sfpf))
  responses <- sfpf[,iorder]
  rownames(responses) <- sfpf$NAME

  rpf.1dim.fit(spec, param, responses, sfpf$MEASURE, 2, wh.exact=TRUE)
## Warning: Excluding item GO TO MUSEUM because outcomes != 3
## Warning: Excluding response ROSSNER, LAWRENCE F. because it is a minimum or maximum
##     n  infit  infit.z outfit outfit.z                            name
## 1  74 0.7335 -1.93854 0.6663 -1.84016                     WATCH BIRDS
## 2  74 0.7558 -1.49110 0.5601 -1.43788           READ BOOKS ON ANIMALS
## 3  74 0.6562 -2.62314 0.6235 -2.50977            READ BOOKS ON PLANTS
## 4  74 0.9886 -0.02982 0.9833 -0.05804              WATCH GRASS CHANGE
## 5  74 2.2855  5.28398 3.9687  6.98046           FIND BOTTLES AND CANS
## 6  74 0.8806 -0.79728 0.8213 -1.02013 LOOK UP STRANGE ANIMAL OR PLANT
## 7  74 0.9695 -0.16907 1.0049  0.08463               WATCH ANIMAL MOVE
## 8  74 1.1684  1.13264 1.2320  1.40768         LOOK IN SIDEWALK CRACKS
## 9  74 1.1126  0.82685 1.1337  0.75931                LEARN WEED NAMES
## 10 74 0.7756 -1.09399 0.5617 -1.14659             LISTEN TO BIRD SING
## 11 74 0.7287 -1.83372 0.5881 -1.68056         FIND WHERE ANIMAL LIVES
## 12 74 0.8493 -0.62542 0.7008 -0.43349                     GROW GARDEN
## 13 74 0.8730 -0.86824 0.8059 -1.13628      LOOK AT PICTURES OF PLANTS
## 14 74 0.7502 -1.67365 0.6058 -1.69066             READ ANIMAL STORIES
## 15 74 1.0934  0.65701 1.0512  0.36543                      MAKE A MAP
## 16 74 0.6633 -2.59175 0.6005 -2.35712          WATCH WHAT ANIMALS EAT
## 17 74 1.2326  0.58992 1.1913  0.50749                    GO ON PICNIC
## 18 74 0.9691  0.02439 1.0925  0.35482                       GO TO ZOO
## 19 74 1.3529  2.12138 1.7997  3.71877                      WATCH BUGS
## 20 74 0.7335 -1.59075 0.5470 -1.51023            WATCH BIRD MAKE NEST
## 21 74 0.8040 -1.40104 0.7128 -1.48373       FIND OUT WHAT ANIMALS EAT
## 22 74 2.3647  5.80478 4.6517  8.53850                     WATCH A RAT
## 23 74 0.7908 -1.42062 0.6910 -1.22075   FIND OUT WHAT FLOWERS LIVE ON
## 24 74 0.7831 -1.61643 0.7215 -1.66986     TALK W FRIENDS ABOUT PLANTS
  head(rpf.1dim.fit(spec, param, responses, sfpf$MEASURE, 1, wh.exact=TRUE))
## Warning: Excluding item GO TO MUSEUM because outcomes != 3
## Warning: Excluding response ROSSNER, LAWRENCE F. because it is a minimum or maximum
##    n  infit  infit.z outfit outfit.z                 name
## 1 24 0.9694 -0.01898 0.8675  -0.2175 ROSSNER, MARC DANIEL
## 2 24 0.4688 -2.24283 0.4341  -1.3590     ROSSNER, TOBY G.
## 3 24 0.7378 -0.97658 0.6784  -0.8997  ROSSNER, MICHAEL T.
## 4 24 0.7941 -0.75849 1.3988   1.1557  ROSSNER, REBECCA A.
## 5 24 1.6391  2.12340 2.5979   3.4654      ROSSNER, TR CAT
## 6 24 1.8561  1.94797 1.2288   0.5464     WRIGHT, BENJAMIN