ferx_plot_trace.RdProduces a two-panel diagnostic plot from the per-iteration trace written
when optimizer_trace = TRUE was passed to ferx_fit.
The top panel shows OFV over iterations; the bottom panel shows a
method-specific convergence metric (gradient norm for gradient-based
methods, MH accept rate for SAEM, LM lambda for Gauss-Newton). Phase
boundaries are drawn as vertical dashed lines.
ferx_plot_trace(fit, log_ofv = FALSE)A ferx_fit object or path to a trace CSV file (see
ferx_trace).
Logical; plot OFV on a log scale relative to the final value
(\(OFV - OFV_{final}\)). Default FALSE.
Invisibly returns the trace data frame (from
ferx_trace).
ex <- ferx_example("warfarin")
fit <- ferx_fit(ex$model, ex$data, method = "gn", covariance = FALSE,
optimizer_trace = TRUE)
#> Warning: Model file [fit_options] sets `method = foce` but ferx_fit() argument overrides it with `gn`. The call-time value will be used.
#> Warning: Model file [fit_options] sets `covariance = true` but ferx_fit() argument overrides it with `false`. The call-time value will be used.
#> Mu-referencing detected for: ETA_CL, ETA_KA, ETA_V
#> Negative IWRES autocorrelation detected (Durbin-Watson = 2.61, lag-1 r = -0.37).
#> Possible over-parameterisation or misspecified residual error model.
tr <- ferx_trace(fit)
head(tr)
#> iter method phase ofv wall_ms grad_norm step_norm inner_iter_count
#> 1 1 gn NA -275.8764 1 NA NA NA
#> 2 2 gn NA -278.5205 2 NA NA NA
#> 3 3 gn NA -279.3926 3 NA NA NA
#> 4 4 gn NA -279.6479 4 NA NA NA
#> 5 5 gn NA -279.8435 5 NA NA NA
#> 6 6 gn NA -279.9383 7 NA NA NA
#> optimizer lm_lambda ofv_delta step_accepted cond_nll gamma mh_accept_rate
#> 1 NA 3.0e-03 -5.952311 1 NA NA NA
#> 2 NA 9.0e-04 -2.644174 1 NA NA NA
#> 3 NA 2.7e-04 -0.872105 1 NA NA NA
#> 4 NA 8.1e-05 -0.255300 1 NA NA NA
#> 5 NA 2.4e-05 -0.195524 1 NA NA NA
#> 6 NA 7.0e-06 -0.094832 1 NA NA NA
#> n_ebe_unconverged n_ebe_fallback
#> 1 NA NA
#> 2 NA NA
#> 3 NA NA
#> 4 NA NA
#> 5 NA NA
#> 6 NA NA