added na.action setting in pcm
This commit is contained in:
4
R/pcm.R
4
R/pcm.R
@ -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
|
||||
|
@ -35,6 +35,8 @@ pcm(
|
||||
\item{fit}{string determining the optimization algorithm. Values "ucminf" or "nlminb" ar recommended}
|
||||
|
||||
\item{method.theta}{string determining the estimation method for individual latent variable values. Either "eap", "mle" or "wle"}
|
||||
|
||||
\item{na.action}{function for treatment of NAs to be passed to model estimation}
|
||||
}
|
||||
\value{
|
||||
A data.frame containing various model outputs
|
||||
|
Reference in New Issue
Block a user