% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mixture_irt.R
\name{mixture_irt}
\alias{mixture_irt}
\title{Mixture Item Response Theory Model (Latent-Class Rasch / 2PL)}
\usage{
mixture_irt(data, n_class = 2, model = "Rasch", control = list())
}
\arguments{
\item{data}{A data frame of dichotomous (0/1) item responses (rows = persons,
columns = items).}

\item{n_class}{Integer. Number of latent classes to estimate (default
\code{2}).}

\item{model}{String. \code{"Rasch"} (default) or \code{"2PL"}; controls
whether class-specific discriminations are estimated.}

\item{control}{A \code{list} of control parameters for the algorithm:
\itemize{
\item \code{max_iter}: Maximum number of EM iterations (default = 100).
\item \code{converge_tol}: Convergence criterion on the log-likelihood
change (default = 1e-4).
\item \code{quad_points}: Number of quadrature points for the within-class
ability distribution (default = 21).
\item \code{theta_range}: Ability grid bounds (default = c(-4, 4)).
\item \code{verbose}: Logical; print progress (default = TRUE).
}}
}
\value{
A list containing:
\itemize{
\item \code{item_params}: A data frame of class-specific item difficulties
(and discriminations for the 2PL model), with one column per class.
\item \code{class_params}: A data frame of estimated mixing proportions for
each latent class.
\item \code{person_params}: A data frame of posterior class-membership
probabilities and the modal (most likely) class for each person.
\item \code{model_fit}: A data frame with the log-likelihood, AIC, BIC,
number of classes, and classification entropy.
}
}
\description{
Fits a mixture item response theory model (Rost, 1990) in which the examinee
population is assumed to consist of a small number of unobserved latent
classes, each with its own set of item parameters. Mixture IRT models are used
to detect qualitatively different response strategies, unmodeled
subpopulations, or classes for which item difficulty ordering differs. The
model is estimated by the Expectation-Maximization algorithm with a fixed
standard-normal ability distribution within each class.
}
\examples{
  # Two classes with reversed difficulty ordering
  set.seed(2025)
  N <- 300; J <- 8
  b1 <- seq(-1.5, 1.5, length.out = J)
  b2 <- rev(b1)
  theta <- rnorm(N)
  cls <- rep(1:2, each = N / 2)
  resp <- matrix(0, N, J)
  for (i in 1:N) {
    b <- if (cls[i] == 1) b1 else b2
    resp[i, ] <- rbinom(J, 1, 1 / (1 + exp(-(theta[i] - b))))
  }
  df <- as.data.frame(resp); names(df) <- paste0("I", 1:J)

  fit <- mixture_irt(df, n_class = 2, model = "Rasch",
                     control = list(max_iter = 30, verbose = FALSE))
  fit$class_params
  head(fit$item_params)
}
\references{
Rost, J. (1990). Rasch models in latent classes: An integration of two
approaches to item analysis. \emph{Applied Psychological Measurement, 14}(3),
271-282.
}
