estimNLR: Nonlinear regression DIF models estimation.

View source: R/estimNLR.R

estimNLRR Documentation

Nonlinear regression DIF models estimation.

Description

Estimates parameters of nonlinear regression models for DIF detection using either nonlinear least squares or maximum likelihood method with various algorithms.

Usage

estimNLR(y, match, group, formula, method, lower, upper, start)

## S3 method for class 'estimNLR'
logLik(object, ...)

## S3 method for class 'estimNLR'
coef(object, ...)

## S3 method for class 'estimNLR'
fitted(object, ...)

## S3 method for class 'estimNLR'
residuals(object, ...)

## S3 method for class 'estimNLR'
print(x, ...)

## S3 method for class 'estimNLR'
vcov(object, sandwich = FALSE, ...)

Arguments

y

numeric: binary vector of responses.

match

numeric: vector of matching criterion.

group

numeric: binary vector of group membership. "0" for reference group, "1" for focal group.

formula

formula: specification of the model. Can be obtained by the formulaNLR() function.

method

character: method used to estimate parameters. The options are "nls" for nonlinear least squares (default), "mle" for maximum likelihood method, and "irls" for maximum likelihood estimation with iteratively reweighted least squares. See Details.

lower

numeric: lower bounds for parameters of model specified in formula.

upper

numeric: upper bounds for parameters of model specified in formula.

start

numeric: initial parameters. Can be obtained by the startNLR() function.

object

an object of "estimNLR" class.

...

other generic parameters for S3 methods.

x

an object of "estimNLR" class.

sandwich

logical: should be sandwich estimator used for covariance matrix of parameters when using method = "nls"? Default is FALSE.

Details

Function offers either non-linear least squares estimation via nls function, maximum likelihood method with "L-BFGS-B" method via optim function, or maximum likelihood method with iteratively reweighted least squares via glm function.

Author(s)

Adela Hladka (nee Drabinova)
Institute of Computer Science of the Czech Academy of Sciences
Faculty of Mathematics and Physics, Charles University
hladka@cs.cas.cz

Patricia Martinkova
Institute of Computer Science of the Czech Academy of Sciences
martinkova@cs.cas.cz

References

Hladka, A. (2021). Statistical models for detection of differential item functioning. Dissertation thesis. Faculty of Mathematics and Physics, Charles University.

Examples

# loading datadata(GMAT)
y <- GMAT[, 1] # item 1
match <- scale(rowSums(GMAT[, 1:20])) # standardized total score
group <- GMAT[, "group"] # group membership variable

# formula for 3PL model with the same guessing for both groups
M <- formulaNLR(model = "3PLcg", type = "both")

# starting values for 3PL model with the same guessing for item 1
start <- startNLR(GMAT[, 1:20], group, model = "3PLcg", parameterization = "classic")
start <- start[[1]][M$M1$parameters]

# nonlinear least squares
(fit_nls <- estimNLR(
  y = y, match = match, group = group,
  formula = M$M1$formula, method = "nls",
  lower = M$M1$lower, upper = M$M1$upper, start = start
))

coef(fit_nls)
logLik(fit_nls)
vcov(fit_nls)
vcov(fit_nls, sandwich = TRUE)
fitted(fit_nls)
residuals(fit_nls)

# maximum likelihood method
(fit_mle <- estimNLR(
  y = y, match = match, group = group,
  formula = M$M1$formula, method = "mle",
  lower = M$M1$lower, upper = M$M1$upper, start = start
))

coef(fit_mle)
logLik(fit_mle)
vcov(fit_mle)
fitted(fit_mle)
residuals(fit_mle)

# iteratively reweighted least squares for 2PL model
M <- formulaNLR(model = "2PL", parameterization = "logistic")
(fit_irls <- estimNLR(
  y = y, match = match, group = group,
  formula = M$M1$formula, method = "irls"
))

coef(fit_irls)
logLik(fit_irls)
vcov(fit_irls)
fitted(fit_irls)
residuals(fit_irls)

drabinova/difNLR documentation built on Feb. 2, 2024, 7:14 p.m.