calculate_DIF_table.Rd
This function calculates DIF statistics for multiple groups using the `difR` package. The function uses the `genDichoDif()` function for generalized logistic regression and the generalized Mantel-Haenszel test. The function returns a table with DIF statistics per item.
calculate_DIF_table(
data,
items,
group,
score = "score",
focal.names = NULL,
thr = NULL,
p.adjust.method = "holm",
method = c("GMH", "genLogistic")
)
Data frame with dichotomous item responses and age
Character vector with item names
Factor or character vector with group names. Must have same length as the number of rows in the data frame.
Data frame with item parameters. Optional.
Optional. Character vector with group names. If omitted, the function will use the unique values of the group variable.
Optional. Threshold for DIF classification using the MH-statistics. If omitted, the function will use the threshold from the `difGMH()` function.
The adjustment method. Defaults to `"holm"`
Character vector with methods to use for DIF analysis. Either `"GMH"` or `"genLogistic"`.
data frame with DIF statistics per item
The function uses the `"holm"` method for p-value adjustment.
library(dscore)
library(childdevdata)
data <- childdevdata::gcdg_nld_smocc
items <- intersect(dscore::get_itemnames(ins = "ddi", order = "indm"), colnames(data))
# Method 1: Use a numeric group variable
group <- ifelse(data$sex == "Male", 1, 0)
focal.names <- 1
# Method 2: Use a character group variable
group <- data$sex
focal.names <- "Male"
# dt <- calculate_DIF_table(data = data, items = items, group = group,
# focal.names = focal.names)