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  -5.36     NA    NA    NA    NA NA
## i3  -1.07   5.68    NA    NA    NA NA
## i4   0.01   4.79  0.80    NA    NA NA
## i5 -14.43 -14.19  5.93 -5.48    NA NA
## i6  -8.41   9.82 11.16 -5.29 17.75 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(  5) =  17.76, log(p) = -5.73
## i2 : n = 1000, S-X2(  5) =  16.50, log(p) = -5.19
## i3 : n = 1000, S-X2(  5) =   9.30, log(p) = -2.33
## i4 : n = 1000, S-X2(  1) =   0.00, log(p) = 0
## i5 : n = 1000, S-X2(  5) =  11.00, log(p) = -2.97
## i6 : n = 1000, S-X2(  5) =  12.16, log(p) = -3.42

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 3.578e-01 -0.69420 0.7836 0.6141
## 1 3.076e-01 -0.08774 0.7427 0.5517
## 2 1.897e-01  0.52288 0.7103 0.5046
## 3 1.012e-01  1.06753 0.6747 0.4552
## 4 3.711e-02  1.49917 0.6685 0.4469
## 5 6.613e-03  1.88940 0.6895 0.4754
## 6 1.878e-05  2.71899 0.7676 0.5892

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