Learn R Programming

cacIRT (version 1.4)

recursive.raw: Recursive computation of conditional total score

Description

Recursively computes the probabilities of each possible total score conditional on ability.

Usage

recursive.raw(ip, theta, D = 1.7)
gen.rec.raw(Pij, theta.names = NULL)

Arguments

ip
Jx3 matrix of item parameters, columns are discrimination, difficulty, and guessing; in that order.
theta
Vector of abilities or points to condition on.
D
The scaling constant for the IRT parameters, defaults to 1.7, alternatively often set to 1.
Pij
Either: (1) an NxJ matrix of probabilities of correct response, where each row corresponds to the respective element in theta and each column represents an item (as in the result of irf()$f) or (2) an NxMxJ array of pro
theta.names
Optional vector to use as row.names in the output matrix. Should correspond to the first dimension of Pij

Value

  • A matrix of theta points by possible total score 0,1, . . . ,J.

Examples

Run this code
theta <- c(-1,0, 1)
params<-matrix(c(1,1,1,1,-2,1,0,1,0,0,0,0),4,3)

#using IRT model and item parameters
rec.mat <- recursive.raw(params, theta)

#using user supplied probability array
Pij.flat <- irf(params, theta)$f

#through matrix input
rec.mat2 <- gen.rec.raw(Pij.flat, theta)

#through array input (this can be generalized to polytomous tests)
Pij.array <- array(NA, dim = c(length(theta), 2, nrow(params)))

Pij.array[,1,] <- 1 - Pij.flat #P(X_j = 0 | theta_i)
Pij.array[,2,] <- Pij.flat     #P(X_j = 1 | theta_i)

rec.mat3 <- gen.rec.raw(Pij.array, theta)

#same results
max(c(rec.mat-rec.mat3, rec.mat2-rec.mat3))

Run the code above in your browser using DataLab