Last data update: 2014.03.03

R: Refine the Q-matrix by minimizing the residual sum of square...
QrefineR Documentation

Refine the Q-matrix by minimizing the residual sum of square (RSS)

Description

Refine the Q-matrix by minimizing the residual sum of square (RSS) betweenn the real responses and ideal responses. Examinee attribute profiles are estimated using the nonparametric method (plain Hamming) implemented by AlphaNP.

Usage

Qrefine(Y, Q, gate=c("AND", "OR"), max.ite = 50)

Arguments

Y

A matrix of binary responses. Rows represent persons and columns represent items. 1=correct, 0=incorrect.

Q

The Q-matrix of the test. Rows represent items and columns represent attributes. 1=attribute required by the item, 0=attribute not required by the item.

gate

"AND": the examinee needs to possess all attributes required by an item in order to answer it correctly; "OR": the examinee needs to possess only one of the attributes required by an item in order to answer it correctly.

max.ite

The maximum number of iterations allowed.

Value

patterns

All possible attribute profiles. Rows represent different patterns of attribute profiles and columns represent attributes. 1=examinee masters the attribute, 0=examinee does not master the attribute.

initial.Q

The initial Q-matrix. Rows represent items and columns represent attributes. 1=attribute required by the item, 0=attribute not required by the item. This is the preliminary Q-matrix to be refined.

initial.class

The row indices of patterns in the initial estimation of examinee attribute profiles.

terminal.class

The The row indices on patterns in the terminal estimation of examinee attribute profiles after the Q-matrix has been refined.

modified.Q

The modified Q-matrix. Rows represent items and columns represent attributes. 1=attribute required by the item, 0=attribute not required by the item.

modified.entries

The modified q-entries. Column 1 is the item ID of the modified entry; column 2 is the attribute ID of the modified entry.

References

Chiu, C. Y. (2013). Statistical Refinement of the Q-matrix in Cognitive Diagnosis. Applied Psychological Measurement, 37(8), 598-618.

See Also

AlphaNP, print.Qrefine, plot.Qrefine

Examples

# Generate item and examinee profiles

natt <- 3
nitem <- 4
nperson <- 16
Q <- rbind(c(1, 0, 0), c(0, 1, 0), c(0, 0, 1), c(1, 1, 1))
alpha <- rbind(c(0, 0, 0), c(1, 0, 0), c(0, 1, 0), c(0, 0, 1), 
  c(1, 1, 0), c(1, 0, 1), c(0, 1, 1), c(1, 1, 1))
alpha <- rbind(alpha, alpha)

# Generate DINA model-based response data

slip <- c(0.1, 0.15, 0.2, 0.25)
guess <- c(0.1, 0.15, 0.2, 0.25)
my.par <- list(slip=slip, guess=guess)

data <- matrix(NA, nperson, nitem)
eta <- matrix(NA, nperson, nitem)

for (i in 1:nperson) {
  for (j in 1:nitem) {
  eta[i, j] <- prod(alpha[i,] ^ Q[j, ])
  P <- (1 - slip[j]) ^ eta[i, j] * guess[j] ^ (1 - eta[i, j])
  u <- runif(1)
  data[i, j] <- as.numeric(u < P)
  }
}

# Generate misspecified Q-matrix

Q_mis <- Q
Q_mis[c(1,2), 1] <- 1 - Q_mis[c(1,2), 1]

# Run Qrefine and create diagnostic plots

Qrefine.out <- Qrefine(data, Q_mis, gate="AND", max.ite=50)
print(Qrefine.out)
plot(Qrefine.out)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(NPCD)
Loading required package: BB
Loading required package: R.oo
Loading required package: R.methodsS3
R.methodsS3 v1.7.1 (2016-02-15) successfully loaded. See ?R.methodsS3 for help.
R.oo v1.20.0 (2016-02-17) successfully loaded. See ?R.oo for help.

Attaching package: 'R.oo'

The following objects are masked from 'package:methods':

    getClasses, getMethods

The following objects are masked from 'package:base':

    attach, detach, gc, load, save

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/NPCD/Qrefine.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Qrefine
> ### Title: Refine the Q-matrix by minimizing the residual sum of square
> ###   (RSS)
> ### Aliases: Qrefine
> 
> ### ** Examples
> 
> # Generate item and examinee profiles
> 
> natt <- 3
> nitem <- 4
> nperson <- 16
> Q <- rbind(c(1, 0, 0), c(0, 1, 0), c(0, 0, 1), c(1, 1, 1))
> alpha <- rbind(c(0, 0, 0), c(1, 0, 0), c(0, 1, 0), c(0, 0, 1), 
+   c(1, 1, 0), c(1, 0, 1), c(0, 1, 1), c(1, 1, 1))
> alpha <- rbind(alpha, alpha)
> 
> # Generate DINA model-based response data
> 
> slip <- c(0.1, 0.15, 0.2, 0.25)
> guess <- c(0.1, 0.15, 0.2, 0.25)
> my.par <- list(slip=slip, guess=guess)
> 
> data <- matrix(NA, nperson, nitem)
> eta <- matrix(NA, nperson, nitem)
> 
> for (i in 1:nperson) {
+   for (j in 1:nitem) {
+   eta[i, j] <- prod(alpha[i,] ^ Q[j, ])
+   P <- (1 - slip[j]) ^ eta[i, j] * guess[j] ^ (1 - eta[i, j])
+   u <- runif(1)
+   data[i, j] <- as.numeric(u < P)
+   }
+ }
> 
> # Generate misspecified Q-matrix
> 
> Q_mis <- Q
> Q_mis[c(1,2), 1] <- 1 - Q_mis[c(1,2), 1]
> 
> # Run Qrefine and create diagnostic plots
> 
> Qrefine.out <- Qrefine(data, Q_mis, gate="AND", max.ite=50)
Iteration: 1
Iteration: 2
> print(Qrefine.out)
The Modified Q-matrix
       Attribute 1 Attribute 2 Attribute 3
Item 1           0           0           1
Item 2           0           1           0
Item 3           0           0           1
Item 4           1           0           1

The Modified Entries
     Item Attribute
[1,]    2         1
[2,]    4         2
[3,]    1         3
> plot(Qrefine.out)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>