On this page

Calculate the likelihood profile of one estimated scalar parameter, that is, the objective of the refitted model with the parameter fixed at each grid value.

Usage

profile_model(
  fit,
  parameter,
  values,
  scale = c("natural", "internal"),
  ncores = 1
)

Arguments

ArgumentDefaultDescription
fitrequired

A fit that holds its inputs and settings (fit$recipe), its estimates and its optimizer bounds.

parameterrequired

Internal name of one estimated scalar parameter in names(fit$opt$par), such as "log_Linf". Fixed parameters, process deviations and the inputs M and survey catchability cannot be profiled. Letter case does not matter.

valuesrequired

Distinct finite grid values, which on the internal scale must lie within the optimizer bounds of the original fit.

scalec("natural", "internal")

"natural" (default) gives values on the natural scale (exp for log_ and mean_log_ parameters, plogis for logit_* parameters, identity for t0); "internal" gives them on the optimizer scale. Parameter names remain the internal names. For a fit with correlation_range = "symmetric", natural correlation values lie between -1 and 1; for an ALSCL fit with t0_lower, natural values of log_t0 are t0 values above t0_lower. Letter case does not matter.

ncores1

Maximum number of socket workers for the grid fits; each fit and its standard errors run on one worker, with the number of starts of the original fit.

Value

A list with parameter, scale, grid (one row per grid value with value, internal_value, objective, delta_nll, run time, process ID, error, warnings and numerical checks), fits (one fit per grid value, without the TMB object), settings (the arguments of each fit), reference_objective (the objective of the original fit), reference_numerical_ok (its verdict of the numerical checks), elapsed (run time of the batch), model and workers (the number of socket workers used). delta_nll is the objective of a grid fit minus reference_objective; negative values are kept.

Details

The other free scalar parameters start from their estimates in the original fit, and fixed values and named NULL entries of the map are kept. At least one other free scalar parameter must remain. A delta_nll below -10⁻⁶ gives a warning, because the grid fit then found a lower objective than the original fit; check the numerical checks of that grid fit and recheck the original fit. A very small negative difference can come from rounding. The profile is conditional on the model and the fixed parameters of the fit. Failed grid points stay in grid. No confidence intervals or chi-square cutoffs are calculated. To compare assumptions outside the model parameters, such as another natural mortality rate, use fit_scenarios().

Additional details from R help

At least one other scalar parameter must be estimated. Grid values must lie within the optimizer bounds of the original fit. The other estimated parameters start from the fitted optimum, and fixed parameters and named NULL releases of the map are kept. A delta_nll below -1 x 10^-6 gives a warning to check the original fit; very small negative differences can come from roundoff. Check the numerical checks of each grid fit as well. The profile is conditional on the model and on the fixed parameters. It gives no confidence interval or chi-square cutoff, and grid fits that fail the numerical checks stay in grid.

Examples

Run the setup before the example. Fitting examples require an R-compatible C++ toolchain; simulation and export examples may write files.

Example setup
library(ALSCL)
library(ggplot2)
library(patchwork)
data("YTF_example")
x <- YTF_example
inputs <- x[c("data.CatL", "data.wgt", "data.mat")]
dat <- x$data.CatL
x <- YTF_example
a <- run_acl(x, silent = TRUE)
values <- exp(a$opt$par[["mean_log_F"]]) * c(0.9, 1, 1.1)
p <- profile_model(a, "mean_log_F", values, scale = "natural", ncores = 2)
p$grid
Example figure
Example figure: profile_model(a, "mean_log_F", values, scale = "natural", ncores = 2)

See also

Search documentation