This function calculates DIF statistics for multiple groups using the `difR` package. The function uses the `difGenLogistic()` function for generalized logistic regression and the `difGMH()` function for the generalized Mantel-Haenszel test. The function returns a table with DIF statistics per item.

calculate_DIF_table(data, items, score, group, levels = NULL, thr = NULL)

Arguments

data

Data frame with dichotomous item responses and age

items

Character vector with item names

score

Data frame with item parameters

group

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

levels

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.

Value

data frame with DIF statistics per item

Details

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

Examples

library(dscore)
data <- dscore::milestones
score <- dscore(data = data, xname = "age", metric = "logit")[["d"]]
items <- intersect(get_itemnames(ins = "ddi", order = "indm"), colnames(data))

calculate_DIF_table(data = data, items = items, group = data$sex, score = score)
#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#> Warning: glm.fit: algorithm did not converge
#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#> Warning: glm.fit: algorithm did not converge
#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#> Warning: glm.fit: algorithm did not converge
#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#> Warning: glm.fit: algorithm did not converge
#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#> Warning: glm.fit: algorithm did not converge
#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#> Warning: glm.fit: algorithm did not converge
#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#> Warning: glm.fit: algorithm did not converge
#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#> Error in n.ppk * diag(rk) - rk %*% t(rk): non-conformable arrays