% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/MAP_Fit.R
\name{MAP_Fit}
\alias{MAP_Fit}
\title{MAP fit object}
\description{
MAP fit object

MAP fit object
}
\details{
An R6 class storing optimization results from maximum a posteriori
(MAP) estimation.
}
\section{Super class}{
\code{\link[BayesRTMB:RTMB_Fit_Base]{BayesRTMB::RTMB_Fit_Base}} -> \code{map_fit}
}
\section{Public fields}{
\if{html}{\out{<div class="r6-fields">}}
\describe{
\item{\code{model}}{The `RTMB_Model` object used for estimation.}

\item{\code{par_vec}}{Parameter vector on the unconstrained scale (constrained values unlisted).}

\item{\code{par}}{Parameter list on the constrained scale.}

\item{\code{par_unc}}{Parameter vector on the unconstrained scale (raw unconstrained values).}

\item{\code{ci_method}}{Method used for CI estimation ("wald", "sampling", or "none").}

\item{\code{objective}}{RTMB objective function object.}

\item{\code{log_ml}}{Log marginal likelihood or related model criterion.}

\item{\code{convergence}}{Optimizer convergence code.}

\item{\code{sd_rep}}{Standard deviation report object.}

\item{\code{df_fixed}}{Summary table for fixed-effect parameters.}

\item{\code{random_effects}}{Random effect estimates.}

\item{\code{df_transform}}{Summary table for transformed parameter estimates.}

\item{\code{df_generate}}{Summary table for generated quantity estimates.}

\item{\code{opt_history}}{A vector of optimize objective history.}

\item{\code{transform}}{List of transformed parameters maintaining their original dimensions.}

\item{\code{generate}}{List of generated quantities maintaining their original dimensions.}

\item{\code{se_samples}}{List of simulated samples for standard error estimation.}

\item{\code{laplace}}{Logical; whether Laplace approximation was used.}

\item{\code{vcov_unc}}{Variance-covariance matrix of parameters in unconstrained space.}

\item{\code{map}}{List; the parameter mapping used.}

\item{\code{marginal_vars}}{Character vector of parameter names requested through `optimize(marginal = ...)`.}

\item{\code{laplace_random_vars}}{Character vector of all parameter names passed to `MakeADFun(random = ...)` during Laplace approximation.}

\item{\code{idx_fix_active}}{Numeric vector; mapping between active parameters and full unconstrained vector.}

\item{\code{show_df}}{Logical; whether to display degrees of freedom in the summary output.}

\item{\code{view}}{Character vector of parameter names to prioritize in summary.}

\item{\code{fallback_needed}}{Logical; whether Hessian/SE fallback was used during optimization.}
}
\if{html}{\out{</div>}}
}
\section{Methods}{
\subsection{Public methods}{
\itemize{
\item \href{#method-map_fit-get_point_estimate}{\code{MAP_Fit$get_point_estimate()}}
\item \href{#method-map_fit-new}{\code{MAP_Fit$new()}}
\item \href{#method-map_fit-ranef}{\code{MAP_Fit$ranef()}}
\item \href{#method-map_fit-draws}{\code{MAP_Fit$draws()}}
\item \href{#method-map_fit-summary}{\code{MAP_Fit$summary()}}
\item \href{#method-map_fit-print}{\code{MAP_Fit$print()}}
\item \href{#method-map_fit-generated_quantities}{\code{MAP_Fit$generated_quantities()}}
\item \href{#method-map_fit-WAIC}{\code{MAP_Fit$WAIC()}}
\item \href{#method-map_fit-diagnose}{\code{MAP_Fit$diagnose()}}
\item \href{#method-map_fit-profile}{\code{MAP_Fit$profile()}}
\item \href{#method-map_fit-clone}{\code{MAP_Fit$clone()}}
}
}
\if{html}{\out{
<details open><summary>Inherited methods</summary>
<ul>
<li><span class="pkg-link" data-pkg="BayesRTMB" data-topic="RTMB_Fit_Base" data-id="EAP"><a href='../../BayesRTMB/html/RTMB_Fit_Base.html#method-RTMB_Fit_Base-EAP'><code>BayesRTMB::RTMB_Fit_Base$EAP()</code></a></span></li>
<li><span class="pkg-link" data-pkg="BayesRTMB" data-topic="RTMB_Fit_Base" data-id="MAP"><a href='../../BayesRTMB/html/RTMB_Fit_Base.html#method-RTMB_Fit_Base-MAP'><code>BayesRTMB::RTMB_Fit_Base$MAP()</code></a></span></li>
<li><span class="pkg-link" data-pkg="BayesRTMB" data-topic="RTMB_Fit_Base" data-id="estimate"><a href='../../BayesRTMB/html/RTMB_Fit_Base.html#method-RTMB_Fit_Base-estimate'><code>BayesRTMB::RTMB_Fit_Base$estimate()</code></a></span></li>
<li><span class="pkg-link" data-pkg="BayesRTMB" data-topic="RTMB_Fit_Base" data-id="fa_rotate"><a href='../../BayesRTMB/html/RTMB_Fit_Base.html#method-RTMB_Fit_Base-fa_rotate'><code>BayesRTMB::RTMB_Fit_Base$fa_rotate()</code></a></span></li>
<li><span class="pkg-link" data-pkg="BayesRTMB" data-topic="RTMB_Fit_Base" data-id="rotate"><a href='../../BayesRTMB/html/RTMB_Fit_Base.html#method-RTMB_Fit_Base-rotate'><code>BayesRTMB::RTMB_Fit_Base$rotate()</code></a></span></li>
</ul>
</details>
}}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-map_fit-get_point_estimate"></a>}}
\if{latex}{\out{\hypertarget{method-map_fit-get_point_estimate}{}}}
\subsection{Method \code{get_point_estimate()}}{
Get point estimate for a target parameter.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{MAP_Fit$get_point_estimate(target, ...)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{target}}{Target parameter name.}

\item{\code{...}}{Additional arguments, ignored for MAP fits.}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
Matrix, array, vector, or scalar point estimate.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-map_fit-new"></a>}}
\if{latex}{\out{\hypertarget{method-map_fit-new}{}}}
\subsection{Method \code{new()}}{
Create a new `MAP_Fit` object.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{MAP_Fit$new(
  model,
  par_vec = NULL,
  par = NULL,
  objective = NULL,
  log_ml = NULL,
  convergence = NULL,
  sd_rep = NULL,
  df_fixed = NULL,
  random_effects = NULL,
  df_transform = NULL,
  df_generate = NULL,
  opt_history = NULL,
  transform = NULL,
  generate = NULL,
  se_samples = NULL,
  par_unc = NULL,
  ci_method = "wald",
  laplace = TRUE,
  map = NULL,
  vcov_unc = NULL,
  marginal_vars = NULL,
  laplace_random_vars = NULL,
  idx_fix_active = NULL,
  show_df = TRUE,
  view = NULL,
  fallback_needed = NULL
)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{model}}{The `RTMB_Model` object used for estimation.}

\item{\code{par_vec}}{Parameter vector on the unconstrained scale (constrained values unlisted).}

\item{\code{par}}{Parameter list on the constrained scale.}

\item{\code{objective}}{The objective function value at the optimum.}

\item{\code{log_ml}}{Log marginal likelihood.}

\item{\code{convergence}}{Optimizer convergence code.}

\item{\code{sd_rep}}{The `sdreport` object from TMB.}

\item{\code{df_fixed}}{Data frame of fixed effects estimates and CIs.}

\item{\code{random_effects}}{Data frame of random effects estimates and CIs.}

\item{\code{df_transform}}{Data frame of transformed parameters.}

\item{\code{df_generate}}{Data frame of generated quantities.}

\item{\code{opt_history}}{Data frame of optimization history.}

\item{\code{transform}}{List of transformed parameters maintaining their original dimensions.}

\item{\code{generate}}{List of generated quantities maintaining their original dimensions.}

\item{\code{se_samples}}{List of simulated samples for standard error estimation.}

\item{\code{par_unc}}{Parameter vector on the unconstrained scale (raw values).}

\item{\code{ci_method}}{Method used for CI estimation ("wald", "sampling", or "none").}

\item{\code{laplace}}{Logical; whether Laplace approximation was used.}

\item{\code{map}}{List; the parameter mapping used.}

\item{\code{vcov_unc}}{Variance-covariance matrix of parameters in unconstrained space.}

\item{\code{marginal_vars}}{Character vector of parameter names requested through `optimize(marginal = ...)`.}

\item{\code{laplace_random_vars}}{Character vector of all parameter names passed to `MakeADFun(random = ...)` during Laplace approximation.}

\item{\code{idx_fix_active}}{Numeric vector; mapping between active parameters and full unconstrained vector.}

\item{\code{show_df}}{Logical; whether to display degrees of freedom in the summary output. Default is TRUE.}

\item{\code{view}}{Character vector of parameter names to prioritize in summary.}

\item{\code{fallback_needed}}{Logical; whether Hessian/SE fallback was used during optimization.}
}
\if{html}{\out{</div>}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-map_fit-ranef"></a>}}
\if{latex}{\out{\hypertarget{method-map_fit-ranef}{}}}
\subsection{Method \code{ranef()}}{
Return random effect estimates as a named list.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{MAP_Fit$ranef()}\if{html}{\out{</div>}}
}

\subsection{Returns}{
A named list of random effect estimates.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-map_fit-draws"></a>}}
\if{latex}{\out{\hypertarget{method-map_fit-draws}{}}}
\subsection{Method \code{draws()}}{
Extract samples from the asymptotic posterior distribution.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{MAP_Fit$draws(
  pars = NULL,
  inc_random = FALSE,
  inc_transform = TRUE,
  inc_generate = TRUE,
  ...
)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{pars}}{Character or numeric vector specifying the names or indices of parameters to extract.}

\item{\code{inc_random}}{Logical; whether to include random effects.}

\item{\code{inc_transform}}{Logical; whether to include transformed parameters.}

\item{\code{inc_generate}}{Logical; whether to include generated quantities.}

\item{\code{...}}{Ignored.}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
An array of samples [iterations, 1, parameters].
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-map_fit-summary"></a>}}
\if{latex}{\out{\hypertarget{method-map_fit-summary}{}}}
\subsection{Method \code{summary()}}{
Summarize MAP estimates.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{MAP_Fit$summary(
  pars = NULL,
  max_rows = 10,
  digits = 5,
  ranef = FALSE,
  view = NULL
)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{pars}}{Character vector specifying the names of parameters to summarize. If NULL, all available parameters are summarized.}

\item{\code{max_rows}}{Maximum number of rows to print in summaries. Default is 10.}

\item{\code{digits}}{Number of digits to print.}

\item{\code{ranef}}{Logical; whether to also display random effect estimates. Default is FALSE.}

\item{\code{view}}{Character vector of parameter names to prioritize or filter by.}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
A summary object, typically a data frame.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-map_fit-print"></a>}}
\if{latex}{\out{\hypertarget{method-map_fit-print}{}}}
\subsection{Method \code{print()}}{
Print a brief summary of the fitted object.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{MAP_Fit$print(pars = NULL, max_rows = 10, digits = 5, ...)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{pars}}{Character vector specifying the names of parameters to summarize.}

\item{\code{max_rows}}{Maximum number of rows to print in summaries.}

\item{\code{digits}}{Number of digits to print.}

\item{\code{...}}{Additional arguments passed to the `summary` method.}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
The object itself, invisibly.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-map_fit-generated_quantities"></a>}}
\if{latex}{\out{\hypertarget{method-map_fit-generated_quantities}{}}}
\subsection{Method \code{generated_quantities()}}{
Compute generated quantities from the MAP estimate.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{MAP_Fit$generated_quantities(code)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{code}}{An `rtmb_code(\{ ... \})` or `\{ ... \}` block containing the logic to be calculated using the MAP estimate.}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
The `MAP_Fit` object itself (invisibly). Results are added or updated in the `generate` list and `df_generate`.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-map_fit-WAIC"></a>}}
\if{latex}{\out{\hypertarget{method-map_fit-WAIC}{}}}
\subsection{Method \code{WAIC()}}{
Compute an approximate WAIC from sampling-based uncertainty propagation.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{MAP_Fit$WAIC()}\if{html}{\out{</div>}}
}

\subsection{Returns}{
A `waic_BayesRTMB` object.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-map_fit-diagnose"></a>}}
\if{latex}{\out{\hypertarget{method-map_fit-diagnose}{}}}
\subsection{Method \code{diagnose()}}{
Run basic diagnostics for the MAP fit.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{MAP_Fit$diagnose(...)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{...}}{Additional arguments passed to `diagnose_map_fit()`.}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
A `diagnose_BayesRTMB` object.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-map_fit-profile"></a>}}
\if{latex}{\out{\hypertarget{method-map_fit-profile}{}}}
\subsection{Method \code{profile()}}{
Calculate Profile Likelihood confidence intervals for specific parameters.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{MAP_Fit$profile(
  pars = NULL,
  level = 0.95,
  trace = FALSE,
  digits = 5,
  show_plot = FALSE,
  quiet = FALSE,
  jacobian = "none",
  ...
)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{pars}}{Character vector of parameter names to profile. If NULL, all fixed parameters are profiled.}

\item{\code{level}}{Confidence level (default is 0.95).}

\item{\code{trace}}{Logical; whether to print profiling progress. Default is FALSE.}

\item{\code{digits}}{Integer; number of decimal places to print. Default is 5.}

\item{\code{show_plot}}{Logical; whether to plot the profile likelihood curves. Default is FALSE.}

\item{\code{quiet}}{Logical; whether to suppress text output. Default is FALSE.}

\item{\code{jacobian}}{Character; "none" (default), "random", or "all". Whether to include Jacobian adjustments for transformations.}

\item{\code{...}}{Additional arguments passed to TMB::tmbprofile (e.g., ytol).}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
A data frame containing the profile-based confidence intervals, with the raw profile objects stored in the "profiles" attribute.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-map_fit-clone"></a>}}
\if{latex}{\out{\hypertarget{method-map_fit-clone}{}}}
\subsection{Method \code{clone()}}{
The objects of this class are cloneable with this method.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{MAP_Fit$clone(deep = FALSE)}\if{html}{\out{</div>}}
}

\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{deep}}{Whether to make a deep clone.}
}
\if{html}{\out{</div>}}
}
}
}
