% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/api-export-bundles.R
\name{build_mfrm_manifest}
\alias{build_mfrm_manifest}
\title{Build a reproducibility manifest for an MFRM analysis}
\usage{
build_mfrm_manifest(
  fit,
  diagnostics = NULL,
  bias_results = NULL,
  population_prediction = NULL,
  unit_prediction = NULL,
  plausible_values = NULL,
  include_person_anchors = FALSE,
  data = NULL
)
}
\arguments{
\item{fit}{Output from \code{\link[=fit_mfrm]{fit_mfrm()}} or \code{\link[=run_mfrm_facets]{run_mfrm_facets()}}.}

\item{diagnostics}{Optional output from \code{\link[=diagnose_mfrm]{diagnose_mfrm()}}. When \code{NULL},
diagnostics are computed with \code{residual_pca = "none"}.}

\item{bias_results}{Optional output from \code{\link[=estimate_bias]{estimate_bias()}} or a named list of
bias bundles.}

\item{population_prediction}{Optional output from
\code{\link[=predict_mfrm_population]{predict_mfrm_population()}}.}

\item{unit_prediction}{Optional output from \code{\link[=predict_mfrm_units]{predict_mfrm_units()}}.}

\item{plausible_values}{Optional output from \code{\link[=sample_mfrm_plausible_values]{sample_mfrm_plausible_values()}}.}

\item{include_person_anchors}{If \code{TRUE}, include person measures in the
exported anchor table.}

\item{data}{Optional original analysis data frame. When supplied,
the manifest's \code{input_hash} row for \code{data} is computed against
the user's untouched input rather than the package's internal
\code{prep$data} (which carries synthesised \code{Weight} / \code{score_k}
columns) so the recorded fingerprint matches what
\code{read.csv()} will produce in a replay session.}
}
\value{
A named list with class \code{mfrm_manifest}.
}
\description{
Build a reproducibility manifest for an MFRM analysis
}
\details{
This helper captures the package-native equivalent of the Streamlit app's
configuration export. It summarizes analysis settings, source columns,
anchoring information, and which downstream outputs are currently available.
}
\section{When to use this}{

Use \code{build_mfrm_manifest()} when you want a compact, machine-readable record
of how an analysis was run. Compared with related helpers:
\itemize{
\item \code{\link[=export_mfrm]{export_mfrm()}} writes analysis tables only.
\item \code{build_mfrm_manifest()} records settings and available outputs.
\item \code{\link[=build_mfrm_replay_script]{build_mfrm_replay_script()}} creates an executable R script.
\item \code{\link[=export_mfrm_bundle]{export_mfrm_bundle()}} writes a shareable folder of files.
}
}

\section{Output}{

The returned bundle has class \code{mfrm_manifest} and includes:
\itemize{
\item \code{summary}: one-row analysis overview
\item \code{environment}: package/R/platform metadata
\item \code{model_settings}: key-value model settings table
\item \code{source_columns}: key-value data-column table
\item \code{estimation_control}: key-value optimizer settings table
\item \code{anchor_summary}: facet-level anchor summary
\item \code{anchors}: machine-readable anchor table
\item \code{hierarchical_review}: retained traceability table for hierarchical /
small-sample design flags
\item \code{missing_recoding}: retained traceability table for missing-code recoding
\item \code{shrinkage_review}: retained traceability table for shrinkage settings
\item \code{available_outputs}: availability table for diagnostics/bias/PCA/prediction
outputs
\item \code{dependencies}, \code{input_hash}, and \code{session_info}: reproducibility
metadata tables
\item \code{settings}: manifest build settings
}
}

\section{Interpreting output}{

The \code{summary} table is the direct place to confirm that you are looking at
the intended analysis. The \code{model_settings}, \code{source_columns}, and
\code{estimation_control} tables are designed for reproducibility records and
method write-up.
Active latent-regression fits also record their population-model provenance
there, including the fitted scoring basis, stored \code{population_formula}, and
person-level contract used by the fitted population model. When categorical
background variables are expanded through \code{stats::model.matrix()},
\code{population_xlevel_variables} and \code{population_contrast_variables} identify
the variables whose fitted coding must be preserved for replay/scoring.
The \code{available_outputs} table is especially useful before building bundles,
because it tells you whether residual PCA, anchors, bias results, or
prediction-side artifacts are already available. A practical reading order is
\code{summary} first, \code{available_outputs} second, and \code{anchors} last when
reproducibility depends on fixed constraints.
}

\section{Typical workflow}{

\enumerate{
\item Fit a model with \code{\link[=fit_mfrm]{fit_mfrm()}} or \code{\link[=run_mfrm_facets]{run_mfrm_facets()}}.
\item Compute diagnostics once with \code{\link[=diagnose_mfrm]{diagnose_mfrm()}} if you want explicit
control over residual PCA.
\item Build a manifest and inspect \code{summary} plus \code{available_outputs}.
\item If you need files on disk, pass the same objects to
\code{\link[=export_mfrm_bundle]{export_mfrm_bundle()}}.
}

For bounded \code{GPCM} fits, the manifest is available with an explicit
\code{gpcm_boundary} table. It records supported direct diagnostics/reporting
surfaces while keeping full FACETS score-side contract review blocked and
routing design forecasting through its separate caveated capability row.
}

\examples{
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")
manifest <- build_mfrm_manifest(fit, diagnostics = diag)
manifest$summary[, c("Model", "Method", "Observations", "Facets")]
manifest$available_outputs[, c("Component", "Available")]
}
\seealso{
\code{\link[=export_mfrm_bundle]{export_mfrm_bundle()}}, \code{\link[=build_mfrm_replay_script]{build_mfrm_replay_script()}},
\code{\link[=make_anchor_table]{make_anchor_table()}}, \code{\link[=reporting_checklist]{reporting_checklist()}}
}
