% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mc.R
\name{distractor_analysis}
\alias{distractor_analysis}
\title{Distractor analysis for multiple-choice items}
\usage{
distractor_analysis(fit, items = NULL, min_n = 10)
}
\arguments{
\item{fit}{A fitted object from \code{\link{rasch}} run with a \code{key}.}

\item{items}{Optional subset of item names; defaults to every keyed item.}

\item{min_n}{Minimum takers for an option to be eligible for the miskey
flag.}
}
\value{
A data frame with one row per item-option: \code{item},
  \code{option}, its assigned \code{score}, \code{keyed} (full credit),
  \code{n}, \code{prop}, \code{mean_location}, \code{point_biserial},
  and \code{flag}.
}
\description{
For every keyed item and response option: the count and proportion
choosing it, the mean location of those persons, and the point-biserial
correlation between choosing the option and the person measure. Locations
and correlations use the rest measure (the person estimate from the other
items), so the analysed item cannot credit its own takers. The keyed
option should attract the ablest persons and carry the only positive
point-biserial; a distractor whose takers are abler than the keyed
option's (with at least \code{min_n} takers) is flagged as a possible
miskey.
}
\examples{
set.seed(1); Np <- 400
th <- rnorm(Np)
raw <- sapply(seq(-1, 1, length.out = 6), function(d) {
  ok <- rbinom(Np, 1, plogis(th - d))
  ifelse(ok == 1, "A", sample(c("B", "C", "D"), Np, replace = TRUE))
})
colnames(raw) <- paste0("M", 1:6)
fit <- rasch(raw, key = setNames(rep("A", 6), colnames(raw)))
head(distractor_analysis(fit))
}
