difstudy | R Documentation |
Functions for estimating differential item functioning (DIF) with a set of scored item responses.
difstudy(
x,
groups,
ref,
scores = NULL,
method = c("mh", "lr"),
anchor_items = 1:ncol(x),
dif_items = 1:ncol(x),
complete = TRUE,
na.rm = FALSE,
p_cut = 0.05,
sdp_w = c("focal", "reference", "total"),
contrast_type = "contr.treatment"
)
x |
matrix or data.frame of scored item responses. |
groups |
vector defining categorical grouping variable. |
ref |
string identifying label used in |
scores |
optional vector of construct scores, defaulting to row sums
over all columns in |
method |
what DIF method to use, with |
anchor_items |
vector of item names or column numbers for
identifying anchoring items in |
dif_items |
vector of item names or column numbers identifying what
items in |
complete |
logical with default |
na.rm |
logical with default |
p_cut |
numeric cutoff for evaluating the p-value for the Mantel-Haenszel chi-square, with default 0.05. |
sdp_w |
string for choosing the weight when finding the standardized difference statistic, defaulting to the number of test takers in the focal group. |
contrast_type |
string for the type of contrasts to use in logistic
regression, defaulting to |
# Vector of item names
ritems <- c("r414q02", "r414q11", "r414q06", "r414q09",
"r452q03", "r452q04", "r452q06", "r452q07", "r458q01",
"r458q07", "r458q04")
rsitems <- paste0(ritems, "s")
# Subset PISA09 to Belgium and Germany
pisa <- subset(PISA09, cnt %in% c("BEL", "DEU"))
x_totals <- rowSums(pisa[, rsitems], na.rm = TRUE)
# Uniform DIF with Mantel-Haenszel
difstudy(x = pisa[, rsitems], groups = pisa$cnt, ref = "BEL",
scores = x_totals, method = "mh")
# Uniform and nonuniform DIF with logistic regression
difstudy(x = pisa[, rsitems], groups = pisa$cnt, ref = "BEL",
method = "lr")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.