Added theta estimation methods

This commit is contained in:
2025-05-06 08:31:24 +02:00
parent a70686cae0
commit 28e43dee33
6 changed files with 34 additions and 8 deletions

View File

@ -8,11 +8,14 @@
#' @param df data.frame containing the data
#' @param items vector containing the names of columns where item responses are stored in df
#' @param grp vector containing the name of the column where an optional group membership variable is stored in df
#' @param method.theta string determining the estimation method for individual latent variable values. Either "eap", "mle" or "wle"
#' @param verbose set to TRUE to print a detailed output, FALSE otherwise
#' @return A data.frame containing a column listing the detected DIF item and another listing detected DIF forms
#' @import vcrpart
#' @import PP
#' @export
residif <- function(df=NULL,items=NULL,grp=NULL,verbose=T) {
residif <- function(df=NULL,items=NULL,grp=NULL,method.theta="eap",verbose=T) {
if (any(!(items %in% colnames(df)))) {
stop("ERROR: provided item name does not exist in df")
}
@ -37,7 +40,7 @@ residif <- function(df=NULL,items=NULL,grp=NULL,verbose=T) {
cat("#################################################################################################\n")
}
startt <- Sys.time()
pcm_initial <- pcm(df = df,items = items,grp = grp,verbose=F)
pcm_initial <- pcm(df = df,items = items,grp = grp,verbose=F,method.theta = method.theta)
dat <- df
dat$score <- rowSums(dat[,items])
nqt <- ifelse(length(unique(quantile(dat$score,seq(0,1,0.2))))==6,5,length(unique(quantile(dat$score,seq(0,1,0.2))))-1)
@ -73,7 +76,7 @@ residif <- function(df=NULL,items=NULL,grp=NULL,verbose=T) {
res.items <- c(res.items,res.item)
res.uni <- res.anova[[numitem]][3,"Pr(>F)"]>0.05
res.uniform <- c(res.uniform,res.uni)
pcm_while <- pcm(df = df,items = items,grp = grp,dif.items = res.items,type.dif = res.uniform,verbose=F)
pcm_while <- pcm(df = df,items = items,grp = grp,dif.items = res.items,type.dif = res.uniform,verbose=F,method.theta = method.theta)
res.anova <- rep(NA,nbitems)
pval <- rep(NA,nbitems_o)
fval <- rep(NA,nbitems_o)