@@ -198,29 +198,21 @@ RCI <- function(mod_pre, predat, postdat,
198198 SE = pse , z = z ,
199199 p = pnorm(abs(z ), lower.tail = FALSE )* 2 )
200200 } else {
201- stop(' multidimensional IRT models not suppported in RCI()' , call. = FALSE )
202- # fs_pre <- fscores(mod_pre, response.pattern=predat, ...)
203- # fs_post <- fscores(mod_post, response.pattern=postdat, ...)
204- # fs_acov <- fs_pre_acov <- fscores(mod_pre, response.pattern = predat,
205- # return.acov=TRUE, ...)
206- # fs_post_acov <- fscores(mod_post, response.pattern=postdat,
207- # return.acov=TRUE, ...)
208- # for(i in 1L:length(fs_acov))
209- # fs_acov[[i]] <- fs_pre_acov[[i]] + fs_post_acov[[i]]
210- # diff <- fs_post[,1L:nfact] - fs_pre[,1L:nfact]
211- # joint <- vector('list', nrow(diff))
212- # for(i in 1:nrow(diff))
213- # joint[[i]] <- wald.test(diff[i,], covB = fs_acov[[i]],
214- # L = diag(ncol(diff)))
215- # joint <- do.call(rbind, joint)
216- # SEs <- do.call(rbind, lapply(fs_acov, \(x) sqrt(diag(x))))
217- # z <- diff/SEs
218- # converge_pre <- converge_post <- rep(TRUE, length(z))
219- # converge_pre[attr(fs_pre, 'failed2converge')] <- FALSE
220- # converge_post[attr(fs_post, 'failed2converge')] <- FALSE
221- # ret <- data.frame(diff=diff, converged=converge_pre & converge_post,
222- # joint, z=z,
223- # p=pnorm(abs(z), lower.tail = FALSE)*2)
201+ # TODO document this later, and include an example
202+ stopifnot(" Must have exactly 2 latent traits" =
203+ extract.mirt(mod_pre , ' nfact' ) == 2 )
204+ if (! missing(postdat ))
205+ stop(' Only mod_pre and predat are required for multidimensional model' )
206+ fs <- fscores(mod_pre , response.pattern = predat , ... )
207+ diff <- fs [,1 ] - fs [,2 ]
208+ pse <- sqrt(fs [,3 ]^ 2 + fs [,4 ]^ 2 )
209+ z <- diff / pse
210+ converge <- rep(TRUE , length(z ))
211+ converge [attr(fs , ' failed2converge' )] <- FALSE
212+ ret <- data.frame (pre.score = fs [,1 ], post.score = fs [,2 ],
213+ converged = converge , diff ,
214+ SE = pse , z = z ,
215+ p = pnorm(abs(z ), lower.tail = FALSE )* 2 )
224216 }
225217 }
226218
0 commit comments