Learn R Programming

difNLR (version 1.3.0)

difNLR: DIF detection using non-linear regression method.

Description

Performs DIF detection procedure for dichotomous data based on non-linear regression model (generalized logistic regression) and either likelihood-ratio or F test of submodel.

Usage

difNLR(Data, group, focal.name, model, constraints, type = "both", method = "nls",
match = "zscore", anchor = NULL, purify = FALSE, nrIter = 10, test = "LR", alpha = 0.05,
p.adjust.method = "none", start, initboot = T, nrBo = 20)

# S3 method for difNLR print(x, ...)

# S3 method for difNLR fitted(object, item = "all", ...)

# S3 method for difNLR coef(object, SE = FALSE, simplify = FALSE, ...)

# S3 method for difNLR logLik(object, item = "all", ...)

# S3 method for difNLR AIC(object, item = "all", ...)

# S3 method for difNLR BIC(object, item = "all", ...)

# S3 method for difNLR residuals(object, item = "all", ...)

Arguments

Data

numeric: either the scored data matrix only, or the scored data matrix plus the vector of group. See Details.

group

numeric or character: either the binary vector of group membership or the column indicator (in Data) of group membership. See Details.

focal.name

numeric or character: indicates the level of group which corresponds to focal group

model

character: generalized logistic regression model to be fitted. See Details.

constraints

character: which parameters should be the same for both groups. See Details.

type

character: type of DIF to be tested. Possible values are "both" (default), "udif", "nudif", "all", or combination of parameters "a", "b", "c" and "d". See Details.

method

character: method used to estimate parameters. The options are "nls" for non-linear least squares (default) and "likelihood" for maximum likelihood method.

match

character or numeric: specifies matching criterion. Can be either "zscore" (default, standardized total score), "score" (total test score), or numeric vector of the same length as number of observations in Data. See Details.

anchor

Either NULL (default) or a vector of item names or item identifiers specifying which items are currently considered as anchor (DIF free) items. Argument is ignored if match is not "zscore" or "score". See Details.

purify

logical: should the item purification be applied? (default is FALSE). See Details.

nrIter

numeric: the maximal number of iterations in the item purification (default is 10).

test

character: test to be performed for DIF detection. Can be either "LR" (default), or "F". See Details.

alpha

numeric: significance level (default is 0.05).

p.adjust.method

character: method for multiple comparison correction. See Details.

start

numeric: list with as many elements as number of items. Each element is a named numeric vector with values representing initial values for parameter estimation. See Details.

initboot

logical: in case of convergence issues, should be starting values recalculated based on bootstraped samples? (default is TRUE). See Details.

nrBo

numeric: the maximal number of iterations for calculation of starting values using bootstraped samples (default is 20).

x

an object of "difNLR" class

...

other generic parameters for S3 methods.

object

an object of 'difNLR' class

item

either character ("all"), or numeric vector, or single number corresponding to column indicators.

SE

logical: should be standard errors also returned? (default is FALSE).

simplify

logical: should the result be simplified to a matrix? (default is FALSE).

Value

The difNLR() function returns an object of class "difNLR". The output is displayed by the print() method.

Item characteristic curves and graphical representation of DIF statistics can be displayed with plot() method. For more details see plot.difNLR. Estimated parameters can be displayed with coef() method.

Fitted values can be extracted by the fitted() method for converged item(s) specified in item argument.

Predicted values are produced by the predict() method for converged item(s) specified in item argument. New data can be introduced with match and group arguments. For more details see predict.difNLR.

Residuals are extracted with the residuals() method for converged item(s) specified in item argument.

Log-likelihood, Akaike's information criterion and Schwarz's Bayesian criterion can be extracted with methods logLik(), AIC(), BIC() for converged item(s) specified in item argument.

Object of class "difNLR" is a list with the following components:

Sval

the values of test statistics.

nlrPAR

the estimates of final model.

nlrSE

the standard errors of estimates of final model.

parM0

the estimates of null model.

seM0

the standard errors of estimates of null model.

covM0

the covariance matrices of estimates of null model.

parM1

the estimates of alternative model.

seM1

the standard errors of estimates of alternative model.

covM1

the covariance matrices of estimates of alternative model.

alpha

numeric: significance level.

DIFitems

either the column indicators of the items which were detected as DIF, or "No DIF item detected".

match

matching criterion.

model

fitted model.

type

character: type of DIF that was tested. If parameters were specified, the value is "other".

types

character: the parameters (specified by user, type has value "other") which were tested for difference.

p.adjust.method

character: method for multiple comparison correction which was applied.

pval

the p-values by likelihood ratio test.

adj.pval

the adjusted p-values by likelihood ratio test using p.adjust.method.

df

the degress of freedom of likelihood ratio test.

test

used test.

purification

purify value.

nrPur

number of iterations in item purification process. Returned only if purify is TRUE.

difPur

a binary matrix with one row per iteration of item purification and one column per item. "1" in i-th row and j-th column means that j-th item was identified as DIF in i-1-th iteration. Returned only if purify is TRUE.

conv.puri

logical: indicating whether item purification process converged before the maximal number nrIter of iterations. Returned only if purify is TRUE.

group

the vector of group membership.

Data

the data matrix.

method

used estimation method.

conv.fail

numeric: number of convergence issues.

conv.fail.which

the indicators of the items which did not converge.

llM0

log-likelihood of null model.

llM1

log-likelihood of alternative model.

Details

DIF detection procedure based on non-linear regression is the extension of logistic regression procedure (Swaminathan and Rogers, 1990).

The Data is a matrix which rows represents scored examinee answers ("1" correct, "0" incorrect) and columns correspond to the items. In addition, Data can hold the vector of group membership. If so, group is a column indicator of Data. Otherwise, group must be a dichotomous vector of the same length as nrow(Data).

The unconstrained form of 4PL generalized logistic regression model for probability of correct answer (i.e., y = 1) is

P(y = 1) = (c + cDif*g) + (d + dDif*g - c - cDif*g)/(1 + exp(-(a + aDif*g)*(x - b - bDif*g))),

where x is by default standardized total score (also called Z-score) and g is group membership. Parameters a, b, c and d are discrimination, difficulty, guessing and inattention. Terms aDif, bDif, cDif and dDif then represent differences between two groups in relevant parameters.

This 4PL model can be further constrained by model and constraints arguments. The arguments model and constraints can be also combined.

The model argument offers several predefined models. The options are as follows: Rasch for 1PL model with discrimination parameter fixed on value 1 for both groups, 1PL for 1PL model with discrimination parameter fixed for both groups, 2PL for logistic regression model, 3PLcg for 3PL model with fixed guessing for both groups, 3PLdg for 3PL model with fixed inattention for both groups, 3PLc (alternatively also 3PL) for 3PL regression model with guessing parameter, 3PLd for 3PL model with inattention parameter, 4PLcgdg for 4PL model with fixed guessing and inattention parameter for both groups, 4PLcgd (alternatively also 4PLd) for 4PL model with fixed guessing for both groups, 4PLcdg (alternatively also 4PLc) for 4PL model with fixed inattention for both groups, or 4PL for 4PL model.

The model can be specified in more detail with constraints argument which specifies what parameters should be fixed for both groups. For example, choice "ad" means that discrimination (a) and inattention (d) are fixed for both groups and other parameters (b and c) are not. The arguments model and constraints can be also item specific if they take a form of vector, where each element correspond to one item. The NA value for constraints means no constraints.

The type corresponds to type of DIF to be tested. Possible values are "both" to detect any DIF caused by difference in difficulty or discrimination (i.e., uniform and/or non-uniform), "udif" to detect only uniform DIF (i.e., difference in difficulty b), "nudif" to detect only non-uniform DIF (i.e., difference in discrimination a), or "all" to detect DIF caused by difference caused by any parameter that can differed between groups. The type of DIF can be also specified in more detail by using combination of parameters a, b, c and d. For example, with an option "c" for 4PL model only the difference in parameter c is tested. The type argument is also item specific.

Argument match represents the matching criterion. It can be either the standardized test score (default, "zscore"), total test score ("score"), or any other continuous or discrete variable of the same length as number of observations in Data.

A set of anchor items (DIF free) can be specified through the anchor argument. It need to be a vector of either item names (as specified in column names of Data) or item identifiers (integers specifying the column number). In case anchor items are provided, only these items are used to compute matching criterion match. If the match argument is not either "zscore" or "score", anchor argument is ignored. When anchor items are provided, purification is not applied.

The p.adjust.method is a character for p.adjust function from the stats package. Possible values are "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none".

The start is a list with as many elements as number of items. Each element is a named numeric vector of length 8 representing initial values for parameter estimation. Specifically, parameters a, b, c, and d are initial values for discrimination, difficulty, guessing and inattention for reference group. Parameters aDif, bDif, cDif and dDif are then differences in these parameters between reference and focal group. If not specified, starting values are calculated with startNLR function.

Missing values are allowed but discarded for item estimation. They must be coded as NA for both, data and group parameters.

In case of convergence issues, with an option initboot = TRUE, the starting values are re-calculated based on bootstraped samples. Newly calculated initial values are applied only to items/models with convergence issues.

In case that model considers difference in guessing or inattention parameter, the different parameterization is used and parameters with standard errors are recalculated by delta method. However, covariance matrices stick with alternative parameterization.

References

Drabinova, A. & Martinkova P. (2017). Detection of Differential Item Functioning with NonLinear Regression: Non-IRT Approach Accounting for Guessing. Journal of Educational Measurement, 54(4), 498-517, https://doi.org/10.1111/jedm.12158.

Swaminathan, H. & Rogers, H. J. (1990). Detecting Differential Item Functioning Using Logistic Regression Procedures. Journal of Educational Measurement, 27, 361-370.

See Also

nls p.adjust plot.difNLR startNLR

Examples

Run this code
# NOT RUN {
# loading data based on GMAT
data(GMAT)

Data  <- GMAT[, 1:20]
group <- GMAT[, "group"]

# Testing both DIF effects using likelihood-ratio test and
# 3PL model with fixed guessing for groups
(x <- difNLR(Data, group, focal.name = 1, model = "3PLcg"))

# Testing both DIF effects using F test and
# 3PL model with fixed guessing for groups
difNLR(Data, group, focal.name = 1, model = "3PLcg", test = "F")

# Testing both DIF effects using LR test,
# 3PL model with fixed guessing for groups
# and Benjamini-Hochberg correction
difNLR(Data, group, focal.name = 1, model = "3PLcg", p.adjust.method = "BH")

# Testing both DIF effects using LR test,
# 3PL model with fixed guessing for groups
# and item purification
difNLR(Data, group, focal.name = 1, model = "3PLcg", purify = T)

# Testing both DIF effects using 3PL model with fixed guessing for groups
# and total score as matching criterion
difNLR(Data, group, focal.name = 1, model = "3PLcg", match = "score")

# Testing uniform DIF effects using 4PL model with the same
# guessing and inattention
difNLR(Data, group, focal.name = 1, model = "4PLcgdg", type = "udif")

# Testing non-uniform DIF effects using 2PL model
difNLR(Data, group, focal.name = 1, model = "2PL", type = "nudif")

# Testing difference in parameter b using 4PL model with fixed
# a and c parameters
difNLR(Data, group, focal.name = 1, model = "4PL", constraints = "ac", type = "b")

# Testing both DIF effects using LR test,
# 3PL model with fixed guessing for groups
# with maximum likelihood estimation method
difNLR(Data, group, focal.name = 1, model = "3PLcg", method = "likelihood")

# Graphical devices
plot(x)
plot(x, item = x$DIFitems)
plot(x, item = 1, group.names = c("Group 1", "Group 2"))
plot(x, plot.type = "stat")

# Coefficients
coef(x)
coef(x, SE = T)
coef(x, SE = T, simplify = T)

# Fitted values
fitted(x)
fitted(x, item = 1)

# Residuals
residuals(x)
residuals(x, item = 1)

# Predicted values
predict(x)
predict(x, item = 1)

# Predicted values for new subjects
predict(x, item = 1, match = 0, group = 1)
predict(x, item = 1, match = 0, group = 0)

# AIC, BIC, log-likelihood
AIC(x); BIC(x); logLik(x)
# AIC, BIC, log-likelihood for the first item
AIC(x, item = 1); BIC(x, item = 1); logLik(x, item = 1)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab