% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dif.R
\name{dif_size}
\alias{dif_size}
\title{DIF magnitude in logits with pairwise comparisons}
\usage{
dif_size(
  fit,
  item,
  by,
  p_adjust = "holm",
  alpha = 0.05,
  flag_logits = 0.5,
  min_n = 20
)
}
\arguments{
\item{fit}{A fitted object from \code{\link{rasch}}.}

\item{item}{Item name or index.}

\item{by}{One or more person-factor names nominated in the fit (several
names give interaction cells), or a grouping vector/data frame with
one entry per person.}

\item{p_adjust}{Familywise adjustment over the pairwise comparisons;
default \code{"holm"}.}

\item{alpha}{Significance level for the adjusted probabilities.}

\item{flag_logits}{Absolute difference flagged as practically
significant.}

\item{min_n}{Levels with fewer responders to the item are dropped (their
resolved locations would be too unstable to compare), with a note.}
}
\value{
A list of class \code{"rasch_dif_size"}: \code{levels} (resolved
  location and SE per level, with its n), \code{pairs} (per comparison:
  difference in logits, SE, z, raw and adjusted p, 95 per cent interval,
  \code{significant}, \code{practical}), the settings, and any notes.
}
\description{
Quantifies differential item functioning on the measurement scale
itself, where practical significance is judged: the item is resolved
into one copy per group (or per cell of a factor combination), the
model is refitted, and the distance between the resolved locations is
the DIF size in logits (Andrich & Marais 2019, ch. 16: a simulated
shift of 0.71 was recovered as 0.75 by exactly this method). Every
pair of levels is compared with a Wald test using the full sandwich
covariance of the resolved locations (for a between-person factor the
persons behind different levels are disjoint, but the shared calibration
of the other items still couples the estimates, so the covariance is
used rather than assumed zero), with familywise adjustment over the
pairs. For a within-person factor -- the same persons behind several
levels, as in a stacked repeated-measures design -- the sandwich carries
no person clustering, so the standard errors are conservative; a note
says so, and \code{\link{dif_contrasts}} handles that case with
person-level differencing. Differences
at least \code{flag_logits} in absolute size are flagged as practically
significant; half a logit is a common working criterion, to be weighed
against the test's targeting and purpose.
}
\details{
For an interaction, supply several factor names: levels are then the
factor-combination cells, which is the post-hoc follow-up to a
significant factor-by-factor term in \code{\link{dif_anova}}.
}
\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] <- 0.8
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")
dif_size(fit, "I3", by = "grp")
}
