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")
)

Arguments

data

Data frame with dichotomous item responses and age

items

Character vector with item names

group

Factor or character vector with group names. Must have same length as the number of rows in the data frame.

score

Data frame with item parameters. Optional.

focal.names

Optional. Character vector with group names. If omitted, the function will use the unique values of the group variable.

thr

Optional. Threshold for DIF classification using the MH-statistics. If omitted, the function will use the threshold from the `difGMH()` function.

p.adjust.method

The adjustment method. Defaults to `"holm"`

method

Character vector with methods to use for DIF analysis. Either `"GMH"` or `"genLogistic"`.

Value

data frame with DIF statistics per item

Details

The function uses the `"holm"` method for p-value adjustment.

Examples

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)