% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/api-tables.R
\name{unexpected_after_bias_table}
\alias{unexpected_after_bias_table}
\title{Build an unexpected-after-adjustment screening report}
\usage{
unexpected_after_bias_table(
  fit,
  bias_results,
  diagnostics = NULL,
  abs_z_min = 2,
  prob_max = 0.3,
  top_n = 100,
  rule = c("either", "both")
)
}
\arguments{
\item{fit}{Output from \code{\link[=fit_mfrm]{fit_mfrm()}}.}

\item{bias_results}{Output from \code{\link[=estimate_bias]{estimate_bias()}}.}

\item{diagnostics}{Optional output from \code{\link[=diagnose_mfrm]{diagnose_mfrm()}} for baseline comparison.}

\item{abs_z_min}{Absolute standardized-residual cutoff.}

\item{prob_max}{Maximum observed-category probability cutoff.}

\item{top_n}{Maximum number of rows to return.}

\item{rule}{Flagging rule: \code{"either"} or \code{"both"}.}
}
\value{
A named list with:
\itemize{
\item \code{table}: unexpected responses after bias adjustment
\item \code{summary}: one-row summary (includes baseline-vs-after counts)
\item \code{thresholds}: applied thresholds
\item \code{facets}: analyzed bias facet pair
}
}
\description{
Build an unexpected-after-adjustment screening report
}
\details{
This helper recomputes expected values and residuals after interaction
adjustments from \code{\link[=estimate_bias]{estimate_bias()}} have been introduced.

\code{summary(t10)} is supported through \code{summary()}.
\code{plot(t10)} is dispatched through \code{plot()} for class
\code{mfrm_unexpected_after_bias} (\code{type = "scatter"}, \code{"severity"},
\code{"comparison"}).
}
\section{Interpreting output}{

\itemize{
\item \code{summary}: before/after unexpected counts and reduction metrics.
\item \code{table}: residual unexpected responses after bias adjustment.
\item \code{thresholds}: screening settings used in this comparison.
}

Large reductions indicate bias terms explain part of prior unexpectedness;
persistent unexpected rows indicate remaining model-data mismatch.
}

\section{Typical workflow}{

\enumerate{
\item Run \code{\link[=unexpected_response_table]{unexpected_response_table()}} as baseline.
\item Estimate bias via \code{\link[=estimate_bias]{estimate_bias()}}.
\item Run \code{unexpected_after_bias_table(...)} and compare reductions.
}
}

\section{Further guidance}{

For a plot-selection guide and a longer walkthrough, see
\link{mfrmr_visual_diagnostics} and
\code{vignette("mfrmr-visual-diagnostics", package = "mfrmr")}.
}

\section{Output columns}{

The \code{table} data.frame has the same structure as
\code{\link[=unexpected_response_table]{unexpected_response_table()}} output, with an additional
\code{BiasAdjustment} column showing the bias correction applied to each
observation's expected value.

The \code{summary} data.frame contains:
\describe{
\item{TotalObservations}{Total observations analyzed.}
\item{BaselineUnexpectedN}{Unexpected count before bias adjustment.}
\item{AfterBiasUnexpectedN}{Unexpected count after adjustment.}
\item{ReducedBy, ReducedPercent}{Reduction in unexpected count.}
}
}

\examples{
toy <- load_mfrmr_data("example_bias")
fit <- fit_mfrm(toy, "Person", c("Rater", "Criterion"), "Score", method = "JML", maxit = 30)
diag <- diagnose_mfrm(fit, residual_pca = "none")
bias <- estimate_bias(fit, diag, facet_a = "Rater", facet_b = "Criterion", max_iter = 2)
t10 <- unexpected_after_bias_table(fit, bias, diagnostics = diag, top_n = 20)
summary(t10)
p_t10 <- plot(t10, draw = FALSE)
p_t10$data$plot
}
\seealso{
\code{\link[=estimate_bias]{estimate_bias()}}, \code{\link[=unexpected_response_table]{unexpected_response_table()}}, \code{\link[=bias_count_table]{bias_count_table()}},
\link{mfrmr_visual_diagnostics}
}
