% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/item_fit.R
\name{item_fit}
\alias{item_fit}
\title{Item Fit Statistics (Infit and Outfit)}
\usage{
item_fit(
  data,
  item_params,
  theta = NULL,
  theta_range = c(-4, 4),
  n_points = 41,
  model = NULL,
  D = 1
)
}
\arguments{
\item{data}{A data frame of item responses (rows = persons, columns = items).
Dichotomous items are 0/1; polytomous items are consecutive integers
starting at 0. Item order must match \code{item_params}.}

\item{item_params}{A data frame of item parameters (the \code{item_params}
element from \code{\link{binary_irt}}, \code{\link{polytomous_irt}}, or
\code{\link{mixed_irt}}).}

\item{theta}{Optional numeric vector of estimated abilities, or a person-
parameter data frame with an \code{ability}/\code{theta} column. If
\code{NULL} (default), abilities are estimated internally by EAP scoring.}

\item{theta_range}{Numeric vector of length 2 giving the ability grid bounds
used for internal EAP scoring (default \code{c(-4, 4)}).}

\item{n_points}{Integer. Number of quadrature points for internal EAP scoring
(default \code{41}).}

\item{model}{Optional model override (see \code{\link{item_info}}).}

\item{D}{Scaling constant for the dichotomous logistic metric (default
\code{1}).}
}
\value{
A data frame with one row per item and the columns:
\itemize{
\item \code{item}: item name.
\item \code{n}: number of responses used.
\item \code{outfit}: outfit mean square (unweighted).
\item \code{outfit_z}: standardized outfit (ZSTD).
\item \code{infit}: infit mean square (information-weighted).
\item \code{infit_z}: standardized infit (ZSTD).
}
Mean-square values near 1 indicate good fit; values above about 1.3-1.5
suggest underfit (noise), and values below about 0.7 suggest overfit
(dependency or redundancy).
}
\description{
Computes item-level fit statistics based on standardized response residuals:
the information-weighted mean square (infit) and the unweighted mean square
(outfit), together with their standardized (ZSTD) transformations. These
statistics flag items whose observed responses depart from the fitted model,
either because of noise in the tails of the ability distribution (outfit) or
near the item location (infit). The statistics are computed for dichotomous
and polytomous items alike.
}
\examples{
  set.seed(123)
  sim <- sim_irt(n_people = 400,
                 item_structure = list(list(model = "2PL", n_items = 8)))
  fit <- binary_irt(sim$resp, model = "2PL", method = "EM",
                    control = list(max_iter = 15, verbose = FALSE))

  item_fit(sim$resp, fit$item_params)
}
\references{
Wright, B. D., & Masters, G. N. (1982). \emph{Rating scale analysis}. MESA
Press.
}
