% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/api-plotting.R
\name{export_mfrm}
\alias{export_mfrm}
\title{Export MFRM results to CSV files}
\usage{
export_mfrm(
  fit,
  diagnostics = NULL,
  output_dir = ".",
  prefix = "mfrm",
  tables = c("person", "facets", "summary", "steps", "measures"),
  overwrite = FALSE
)
}
\arguments{
\item{fit}{Output from \code{\link{fit_mfrm}}.}

\item{diagnostics}{Optional output from \code{\link{diagnose_mfrm}}.
When provided, enriches facet estimates with SE, fit statistics, and
writes the full measures table.}

\item{output_dir}{Directory for CSV files. Created if it does not exist.}

\item{prefix}{Filename prefix (default \code{"mfrm"}).}

\item{tables}{Character vector of tables to export. Any subset of
\code{"person"}, \code{"facets"}, \code{"summary"}, \code{"steps"},
\code{"measures"}. Default exports all available tables.}

\item{overwrite}{If \code{FALSE} (default), refuse to overwrite existing
files.}
}
\value{
Invisibly, a data.frame listing written files with columns
\code{Table} and \code{Path}.
}
\description{
Writes tidy CSV files suitable for import into spreadsheet software or
further analysis in other tools.
}
\section{Exported files}{

\describe{
\item{\code{{prefix}_person_estimates.csv}}{Person ID, Estimate, SD.}
\item{\code{{prefix}_facet_estimates.csv}}{Facet, Level, Estimate,
and optionally SE, Infit, Outfit, PTMEA when diagnostics supplied.}
\item{\code{{prefix}_fit_summary.csv}}{One-row model summary.}
\item{\code{{prefix}_step_parameters.csv}}{Step/threshold parameters.}
\item{\code{{prefix}_measures.csv}}{Full measures table (requires
diagnostics).}
}
}

\section{Interpreting output}{

The returned data.frame tells you exactly which files were written and where.
This is convenient for scripted pipelines where the output directory is created
on the fly.
}

\section{Typical workflow}{

\enumerate{
\item Fit a model with \code{\link{fit_mfrm}()}.
\item Optionally compute diagnostics with \code{\link{diagnose_mfrm}()} when you want enriched facet or measures exports.
\item Call \code{export_mfrm(...)} and inspect the returned \code{Path} column.
}
}

\examples{
toy <- load_mfrmr_data("example_core")
fit <- fit_mfrm(toy, "Person", c("Rater", "Criterion"), "Score",
                method = "JML", model = "RSM", maxit = 30)
diag <- diagnose_mfrm(fit, residual_pca = "none")
out <- export_mfrm(
  fit,
  diagnostics = diag,
  output_dir = tempdir(),
  prefix = "mfrmr_example",
  overwrite = TRUE
)
out$Table
}
\seealso{
\code{\link{fit_mfrm}}, \code{\link{diagnose_mfrm}},
\code{\link{as.data.frame.mfrm_fit}}
}
