Estimates per-item discriminations a_j and intercepts d_j by maximizing
the IRT marginal likelihood under a standard-normal ability prior using
L-BFGS-B. The response probability is plogis(d + a * theta), where a is
the discrimination and d is the intercept. Difficulty is returned as
b = -d / a.
Usage
fit_2pl(
resp,
n_quad = 31,
initial_pars = NULL,
quadrature = NULL,
slope_lower = 1e-04,
slope_upper = NULL,
control = list(maxit = 500)
)Arguments
- resp
A numeric item response matrix with rows for subjects and columns for items. Values must be binary
0/1;NAis allowed.- n_quad
Number of standard-normal quadrature nodes.
- initial_pars
Optional starting item parameters (matrix or data frame with
a/a1anddcolumns). If omitted,a_j = 1andd_j = qlogis(p_j)wherep_jis the observed proportion correct for itemj.- quadrature
Optional quadrature grid with
thetaandweightcolumns.- slope_lower, slope_upper
Bounds on the discriminations.
NULLleaves the corresponding side unbounded.- control
Control list passed to
stats::optim().
Value
A list with pars, a data frame containing item, a, d, and
b; par, the raw parameter vector; optimizer details (value,
convergence, message); and model, which is NULL and retained for
backward compatibility.
Details
This is the 2PL counterpart of fit_1pl() and uses the same marginal
likelihood, quadrature, and gradient machinery as
fit_mixed_subjects_mml() at lambda = 0, so a human-only baseline fit and
the mixed-subjects estimator are optimized on a common objective.
See also
fit_1pl() for the shared-discrimination version.
Examples
set.seed(1)
pars <- data.frame(a = c(1, 1.2, 0.9, 1.1, 0.8), d = c(0, 0.5, -0.5, 0.2, -0.3))
resp <- simulate_2pl(rnorm(500), pars)
fit <- fit_2pl(resp)
fit$pars
#> item a d b
#> 1 1 1.4084028 -0.04161168 0.02954530
#> 2 2 0.7733562 0.59261605 -0.76629121
#> 3 3 0.6796751 -0.40146365 0.59066992
#> 4 4 1.2116623 0.10508500 -0.08672796
#> 5 5 0.6915083 -0.32087732 0.46402525