sim_RT {hmcdm}R Documentation

Simulate item response times based on Wang et al.'s (2018) joint model of response times and accuracy in learning

Description

Simulate a cube of subjects' response times across time points according to a variant of the logNormal model

Usage

sim_RT(alphas, Q_matrix, Design_array, RT_itempars, taus, phi, G_version)

Arguments

alphas

An N-by-K-by-T array of attribute patterns of all persons across T time points

Q_matrix

A J-by-K Q-matrix for the test

Design_array

A N-by-J-by-L array indicating whether item j is administered to examinee i at l time point.

RT_itempars

A J-by-2 matrix of item time discrimination and time intensity parameters

taus

A length N vector of latent speed of each person

phi

A scalar of slope of increase in fluency over time due to covariates (G)

G_version

An int of the type of covariate for increased fluency (1: G is dichotomous depending on whether all skills required for current item are mastered; 2: G cumulates practice effect on previous items using mastered skills; 3: G is a time block effect invariant across subjects with different attribute trajectories)

Value

A cube of response times of subjects on each item across time

Examples

N = dim(Design_array)[1]
J = nrow(Q_matrix)
K = ncol(Q_matrix)
L = dim(Design_array)[3]
class_0 <- sample(1:2^K, N, replace = TRUE)
Alphas_0 <- matrix(0,N,K)
mu_thetatau = c(0,0)
Sig_thetatau = rbind(c(1.8^2,.4*.5*1.8),c(.4*.5*1.8,.25))
Z = matrix(rnorm(N*2),N,2)
thetatau_true = Z%*%chol(Sig_thetatau)
thetas_true = thetatau_true[,1]
taus_true = thetatau_true[,2]
G_version = 3
phi_true = 0.8
for(i in 1:N){
  Alphas_0[i,] <- inv_bijectionvector(K,(class_0[i]-1))
}
lambdas_true <- c(-2, .4, .055)     
Alphas <- sim_alphas(model="HO_joint", 
                     lambdas=lambdas_true, 
                     thetas=thetas_true, 
                     Q_matrix=Q_matrix, 
                     Design_array=Design_array)
RT_itempars_true <- matrix(NA, nrow=J, ncol=2)
RT_itempars_true[,2] <- rnorm(J,3.45,.5)
RT_itempars_true[,1] <- runif(J,1.5,2)
ETAs <- ETAmat(K,J,Q_matrix)
L_sim <- sim_RT(Alphas,Q_matrix,Design_array,RT_itempars_true,taus_true,phi_true,G_version)

[Package hmcdm version 2.1.1 Index]