This function returns the log-likelihood of a particular examinee's responses to a set of cognitive diagnostic items. Currently supported cognitive diagnostic models include the DINA model, DINO model, NIDA model, G-NIDA model, and R-RUM model. This function is called by the AlphaMLE function and the JMLE function in the package.
Usage
CDL(Y, Q, par, alpha, model = c("DINA", "DINO", "NIDA", "GNIDA", "RRUM"),
undefined.flag)
Arguments
Y
A vector of binary examinee responses. 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.
par
A list of parameters.
DINA & DINO — par$slip: a vector of slipping parameters for each item;
par$guess: a vector of guessing parameters for each item.
NIDA — par$slip: a vector of slipping parameters for each attribute;
par$guess: a vector of guessing parameters for each attribute.
GNIDA — par$slip: a matrix (items by attributes) of slipping parameters;
par$guess: a matrix (items by attributes) of guessing parameters.
RRUM — par$pi: a vector of pi parameters for each item;
par$r: a matrix (items by attributes) of r parameters.
alpha
A vector of examinee ability profile. 1=examinee masters the attribute, 0=examinee does not master the attribute.
model
Currently supports five models: "DINA", "DINO", "NIDA", "GNIDA", and "RRUM". The default is "DINA".
undefined.flag
A binary vector indicating whether the parameters of each item are undefined. 1=undefined, 0=defined.
Value
loglike
The log likelihood function value for the given data.
See Also
AlphaMLE, JMLE
Examples
# Generate item and examinee profiles
nitem <- 4
Q <- rbind(c(1, 0, 0), c(0, 1, 0), c(0, 0, 1), c(1, 1, 1))
alpha <- c(1, 0, 0)
# Generate DINA model-based response data
slip <- rep(0.1, nitem)
guess <- rep(0.1, nitem)
my.par <- list(slip=slip, guess=guess)
data <- NA
eta <- NA
for (i in 1:nitem) {
eta[i] <- prod(alpha ^ Q[i, ])
P <- (1 - slip[i]) ^ eta[i] * guess[i] ^ (1 - eta[i])
u <- runif(1)
data[i] <- as.numeric(u < P)
}
# Using the function to compute the log-likelihood of the given data
CDL(data, Q, my.par, alpha, model="DINA", undefined.flag=rep(0, nitem))
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/CDL.Rd_%03d_medium.png", width=480, height=480)
> ### Name: CDL
> ### Title: Log-likelihood for cognitive diagnostic models
> ### Aliases: CDL
>
> ### ** Examples
>
> # Generate item and examinee profiles
>
> nitem <- 4
> Q <- rbind(c(1, 0, 0), c(0, 1, 0), c(0, 0, 1), c(1, 1, 1))
> alpha <- c(1, 0, 0)
>
> # Generate DINA model-based response data
>
> slip <- rep(0.1, nitem)
> guess <- rep(0.1, nitem)
> my.par <- list(slip=slip, guess=guess)
>
> data <- NA
> eta <- NA
>
> for (i in 1:nitem) {
+ eta[i] <- prod(alpha ^ Q[i, ])
+ P <- (1 - slip[i]) ^ eta[i] * guess[i] ^ (1 - eta[i])
+ u <- runif(1)
+ data[i] <- as.numeric(u < P)
+ }
>
> # Using the function to compute the log-likelihood of the given data
>
> CDL(data, Q, my.par, alpha, model="DINA", undefined.flag=rep(0, nitem))
[1] -0.4214421
>
>
>
>
>
> dev.off()
null device
1
>