% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/write_files.R
\name{estimate_and_write}
\alias{estimate_and_write}
\title{Run estimation and write standard output files}
\usage{
estimate_and_write(
  model_system,
  factor_model,
  control,
  data = NULL,
  results_dir
)
}
\arguments{
\item{model_system}{model_system object}

\item{factor_model}{factor_model object}

\item{control}{estimation_control object}

\item{data}{Optional data frame (to save as simulated_data.csv)}

\item{results_dir}{Directory for writing output files. This argument is
required; the function writes nothing without an explicit path. Use
\code{tempdir()} in examples or tests.}
}
\value{
Invisibly returns a list with two components: \code{results} (a
data frame of initial parameter values per component, as produced by
\code{estimate_model()}) and \code{packed} (a list with \code{values} and
\code{ses} giving the packed parameter vector and standard errors written
to \code{meas_par.csv}). Called primarily for the side effect of writing
\code{model_config.csv}, \code{meas_par.csv}, \code{system_inits_long.csv},
and optionally \code{simulated_data.csv} into \code{results_dir}.
}
\description{
Calls estimate_model(), then writes the four expected output files:
\itemize{
\item model_config.csv
\item meas_par.csv
\item system_inits_long.csv
\item simulated_data.csv
}
}
