% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/subtests.R
\name{split_items}
\alias{split_items}
\title{Split items by a person factor to resolve DIF}
\usage{
split_items(fit, items, by)
}
\arguments{
\item{fit}{A fitted object from \code{\link{rasch}}.}

\item{items}{Character vector naming the item(s) to split.}

\item{by}{The name of a person factor nominated in the fit, or a grouping
vector with one entry per person.}
}
\value{
A new \code{\link{rasch}} fit in which each split item appears as
  \code{"item (level)"}, with the splits recorded in its notes.
}
\description{
Replaces each nominated item with one item per level of a person factor,
each carrying that level's responses only (other levels missing). Every
group then receives its own item location, which resolves the invariance
violation flagged by \code{\link{dif_anova}}; the distance between the
split locations estimates the DIF size. The model is refitted with the
same settings.
}
\examples{
set.seed(1); n <- 600
d <- seq(-2, 2, length.out = 8); g <- rep(c("a", "b"), each = n / 2)
sh <- matrix(0, n, 8); sh[g == "b", 3] <- 1
X <- matrix(rbinom(n * 8, 1, plogis(outer(rnorm(n), d, "-") - sh)), n, 8)
colnames(X) <- paste0("I", 1:8)
fit <- rasch(data.frame(X, grp = g), factors = "grp")
fit2 <- split_items(fit, "I3", by = "grp")
fit2$items$item
}
