% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/api-tables.R
\name{write_mfrm_residual_file}
\alias{write_mfrm_residual_file}
\title{Write a standalone residual file}
\usage{
write_mfrm_residual_file(
  fit,
  diagnostics = NULL,
  path,
  format = c("csv", "tsv"),
  digits = 4,
  overwrite = FALSE,
  include_probabilities = FALSE
)
}
\arguments{
\item{fit}{Output from \code{\link[=fit_mfrm]{fit_mfrm()}}.}

\item{diagnostics}{Optional output from \code{\link[=diagnose_mfrm]{diagnose_mfrm()}}. Supplying it
avoids recomputing observation diagnostics.}

\item{path}{Output file path.}

\item{format}{File format: \code{"csv"} or \code{"tsv"}. If omitted, inferred from
\code{path} when the extension is \code{.csv} or \code{.tsv}, otherwise \code{"csv"}.}

\item{digits}{Rounding digits for numeric columns.}

\item{overwrite}{If \code{FALSE}, existing files are not overwritten.}

\item{include_probabilities}{If \code{TRUE}, append model probabilities for all
response categories as \verb{PrCategory_*} columns.}
}
\value{
A bundle with \code{table}, \code{summary}, \code{written_files}, and \code{settings}.
}
\description{
Write a standalone residual file
}
\details{
The exported table is observation-level and model-native. It includes the
observed score, expected score, residual, standardized residual, variance,
score information, observed-category probability, and modeled person
measure when those quantities are available.

This writer is separate from \code{\link[=facets_output_file_bundle]{facets_output_file_bundle()}} because it is a
direct analysis handoff rather than a legacy graph/score bundle.
}
\examples{
\donttest{
toy <- load_mfrmr_data("example_core")
fit <- fit_mfrm(toy, "Person", c("Rater", "Criterion"), "Score",
                method = "JML", maxit = 30)
diag <- diagnose_mfrm(fit, residual_pca = "none")
path <- tempfile(fileext = ".csv")
out <- write_mfrm_residual_file(fit, diag, path, overwrite = TRUE)
out$written_files
}
}
\seealso{
\code{\link[=diagnose_mfrm]{diagnose_mfrm()}}, \code{\link[=facets_output_file_bundle]{facets_output_file_bundle()}},
\code{\link[=write_mfrm_subset_file]{write_mfrm_subset_file()}}
}
