g3_iterative | R Documentation |
Perform multiple optimisation runs of a model, reweighting with each run
g3_iterative(
gd,
wgts = "WGTS",
model,
params.in,
grouping = list(),
use_parscale = TRUE,
method = "BFGS",
control = list(),
shortcut = FALSE,
cv_floor = 0,
resume_final = FALSE,
serial_compile = FALSE,
mc.cores = parallel::detectCores()
)
gd |
Directory to store output |
wgts |
Directory name within gd to store run outputs |
model |
A G3 model, produced by g3_to_r() or g3_tmb_adfun() |
params.in |
Initial parameters to use with the model |
grouping |
List of component names to optmise together |
use_parscale |
Logical indicating whether optim(control$parscale) should be used |
method |
The optimisation method, see |
control |
List of control options for optim, see |
shortcut |
If TRUE, weights for each component will be approximated and a final optimisation performed |
cv_floor |
Minimum value of survey components (adist_surveyindices) as 1/ |
resume_final |
Logical value. If TRUE the re-weighting procedure starts at the second stage. |
serial_compile |
g3_tmb_adfun will be run in serial mode (i.e., not in parallel), potentially helping with memory issues |
mc.cores |
number of cores used, defaults to the number of available cores |
An implementation of the iterative reweigthing of likelihood components in gadget. It analyzes a given gadget model and, after a series of optimisations where each likelihood component is heavily weigthed, suggests a weigthing for the components based on the respective variance. If one (or more) components, other than understocking and penalty, are 0 then the gadget optimisation with the final weights will not be completed.
In Taylor et. al an objective reweighting scheme for likelihood components is described for cod in Icelandic waters. The authors nota that the issue of component weighting has been discussed for some time, as the data sources have different natural scales (e.g g vs. kg) that should not affect the outcome. A simple heuristic, where the weights are the inverse of the initial sums of squares for the respective component resulting in an initials score equal to the number of components, is therfor often used. This has the intutitive advantage of all components being normalised. There is however a drawback to this since the component scores, given the initial parametrisation, are most likely not equally far from their respective optima resulting in sub-optimal weighting. The iterative reweighting heuristic tackles this problem by optimising each component separately in order to determine the lowest possible value for each component. This is then used to determine the final weights. The resoning for this approach is as follows: Conceptually the likelihood components can be thought of as residual sums of squares, and as such their variance can be esimated by dividing the SS by the degrees of freedom. The optimal weighting strategy is the inverse of the variance. Here the iteration starts with assigning the inverse SS as the initial weight, that is the initial score of each component when multiplied with the weight is 1. Then an optimisation run for each component with the intial score for that component set to 10000. After the optimisation run the inverse of the resulting SS is multiplied by the effective number of datapoints and used as the final weight for that particular component. The effective number of datapoints is used as a proxy for the degrees of freedom is determined from the number of non-zero datapoints. This is viewed as satisfactory proxy when the dataset is large, but for smaller datasets this could be a gross overestimate. In particular, if the surveyindices are weigthed on their own while the yearly recruitment is esimated they could be overfitted. If there are two surveys within the year Taylor et. al suggest that the corresponding indices from each survey are weigthed simultaneously in order to make sure that there are at least two measurement for each yearly recruit, this is done through component grouping which is implemented.
Component grouping is oftern applied in cases where overfitting is likely, and this can also happen with catch composition data as well as survey indices.
In addition to grouping, a maximum weight can be assigned survey indices vie the cv_floor setting. The cv_floor parameter sets the minimum of the estimated component variance and thus the maximum of the inverser variance.
Weights are calculated using inverse-variance weighting (1/\sigma^2
), and as 1/pmax(variance, cv_floor)
, hence the minimum value for survey components is 1/cv_floor
. Use smaller cv_floor
values to increase the weight of survey components.
Final set of parameters
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.