calculate_DIF_table.Rd
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)
Data frame with dichotomous item responses and age
Character vector with item names
Data frame with item parameters
Factor or character vector with group names. Must have same length as the number of rows in the data frame.
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.
data frame with DIF statistics per item
The function uses the `"holm"` method for p-value adjustment.
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