added na.action setting in pcm

This commit is contained in:
2025-06-03 15:53:56 +02:00
parent 66a3500d44
commit f9bcebbec3
2 changed files with 4 additions and 2 deletions

View File

@ -14,6 +14,7 @@
#' @param verbose set to TRUE to print a detailed output, FALSE otherwise
#' @param fit string determining the optimization algorithm. Values "ucminf" or "nlminb" ar recommended
#' @param method.theta string determining the estimation method for individual latent variable values. Either "eap", "mle" or "wle"
#' @param na.action function for treatment of NAs to be passed to model estimation
#' @return A data.frame containing various model outputs
#' @import vcrpart
#' @import PP
@ -270,7 +271,6 @@ pcm <- function(df=NULL,items=NULL,grp=NULL,dif.items=NULL,type.dif=NULL,weights
}
}
if (is.null(grpo)) {
if (method.theta=="eap") {
theta <- c(-1*ranef(mod,norm=F)+ ifelse(is.null(grpo),0, ifelse(grp==1,beta,0) ) )
} else if (method.theta=="wle") {
@ -278,7 +278,7 @@ pcm <- function(df=NULL,items=NULL,grp=NULL,dif.items=NULL,type.dif=NULL,weights
} else if (method.theta=="mle") {
theta <- PP::PP_gpcm(as.matrix(df[,items]),t(restab),rep(1,length(items)),type="mle")$resPP$resPP[,1]
}
}
resid <- apply(matrix(1:nbitems,ncol=length(nbitems)),1, function(k) sapply(1:nrow(df), function(j) resi(theta[j],restab[k,],df[j,items[k]],beta=0)))
colnames(resid) <- items_o