- pnll
penalised negative log-likelihood function that is structured as dictated by RTMB and uses the penalty function from LaMa to compute the penalty
Needs to be a function of the named list of initial parameters par only.
- par
named list of initial parameters
The random effects/ spline coefficients can be vectors or matrices, the latter summarising several random effects of the same structure, each one being a row in the matrix.
- dat
initial data list that contains the data used in the likelihood function, hyperparameters, and the initial penalty strength vector
If the initial penalty strength vector is not called lambda, the name it has in dat needs to be specified using the psname argument below.
Its length needs to match the to the total number of random effects.
- random
vector of names of the random effects/ penalised parameters in par
Caution: The ordering of random needs to match the order of the random effects passed to penalty inside the likelihood function.
- map
optional map argument, containing factor vectors to indicate parameter sharing or fixing.
Needs to be a named list for a subset of fixed effect parameters or penalty strength parameters.
For example, if the model has four penalty strength parameters, map[[psname]] could be factor(c(NA, 1, 1, 2)) to fix the first penalty strength parameter, estimate the second and third jointly, and estimate the fourth separately.
- silent
integer silencing level: 0 corresponds to full printing of inner and outer iterations, 1 to printing of outer iterations only, and 2 to no printing.
- psname
optional name given to the penalty strength parameter in dat. Defaults to "lambda".
- alpha
optional hyperparamater for exponential smoothing of the penalty strengths.
For larger values smoother convergence is to be expected but the algorithm may need more iterations.
- smoothing
optional scaling factor for the final penalty strength parameters
Increasing this beyond one will lead to a smoother final model. Can be an integer or a vector of length equal to the length of the penalty strength parameter.
- maxiter
maximum number of iterations in the outer optimisation over the penalty strength parameters.
- tol
Convergence tolerance for the penalty strength parameters.
- max_halve
maximum number of step halvings per outer iteration.
After each update of the penalty strength parameters, the restricted log-likelihood is compared to its value in the previous iteration.
If it decreased, the step (on the log scale) is repeatedly halved until it does not, or until max_halve halvings have been made.
This makes the outer iteration monotone and hence more robust. Set to zero to switch step halving off.
- method
optimisation method to be used by optim. Defaults to "BFGS", but might be changed to "L-BFGS-B" for high-dimensional settings.
- control
list of control parameters for optim to use in the inner optimisation. Here, optim uses the BFGS method which cannot be changed.
We advise against changing the default values of reltol and maxit as this can decrease the accuracy of the Laplace approximation.
- conv_crit
character, convergence criterion for the penalty strength parameters. Can be "relchange" (default) or "gradient".
- spHess
logical, if TRUE, sparse AD Hessian is used in each outer iteration. If your Hessian is large and sparse (many cross derivatives are 0), this will speed up the computations a lot.
If your Hessian is dense, this will slow down the computations slightly and might require significantly more memory.
- joint_unc
logical, if TRUE, joint RTMB object is returned allowing for joint uncertainty quantification
- saveall
logical, if TRUE, then all model objects from each iteration are saved in the final model object.