This is the core optimisation function for MortalityLaw. It:
Subsets the data to the fitting ages (fit.this.x).
Scales the age vector if required by the chosen model.
Obtains default starting parameters (if not provided).
Minimises the objective function using nlminb (PORT
routines) with the parameters on the log scale.
Transforms parameters back to the original scale, computes the fitted hazard, and derives goodness-of-fit measures (AIC, BIC, log-likelihood) where applicable.
choose_optim(input)A list with components:
Age vector (original).
Age vector after optional scaling.
Object returned by nlminb.
Estimated parameters on the original scale.
Fitted hazard values evaluated at new.x.
Goodness-of-fit measures (NaN for
non-likelihood methods).
A list containing all input arguments to MortalityLaw.