mrds_opt {mrds} | R Documentation |
Tips on optimisation issues in mrds
models
Description
Occasionally when fitting an 'mrds' model one can run into optimisation issues. In general such problems can be quite complex so these "quick fixes" may not work. If you come up against problems that are not fixed by these tips, or you feel the results are dubious please go ahead and contact the package authors.
Debug mode
One can obtain debug output at each stage of the optimisation using the
showit
option. This is set via control
, so adding
control=list(showit=3)
gives the highest level of debug output
(setting showit
to 1 or 2 gives less output).
Re-scaling covariates
Sometimes convergence issues in covariate (MCDS) models are caused by values
of the covariate being very large, so a rescaling of that covariate is then
necessary. Simply scaling by the standard deviation of the covariate can
help (e.g. dat$size.scaled <- dat$scale/sd(dat$scale)
for a covariate
size
, then including size.scaled
in the model instead of
size
).
It is important to note that one needs to use the original covariate (size) when computing Horvitz-Thompson estimates of population size if the group size is used in that estimate. i.e. use the unscaled size in the numerator of the H-T estimator.
Factor levels
By default R will set the base factor level to be the label which comes
first alphabetically. Sometimes this can be an issue when that factor level
corresponds to a subset of the data with very few observations. This can
lead to very large uncertainty estimates (CVs) for model parameters. One way
around this is to use relevel
to set the base level to a level
with more observations.
Initial values
Initial (or starting) values for the dsmodel can be set via the initial
element of the control
list. initial
is a list itself with
elements scale
, shape
and adjustment
, corresponding to
the associated parameters. If a model has covariates then the scale
or
shape
elements will be vectors with parameter initial values in the
same order as they are specific in the model formula (using showit
is
a good check they are in the correct order). Adjustment starting values are
in order of the order of that term (cosine order 2 is before cosine order 3
terms).
One way of obtaining starting values is to fit a simpler model first (say with fewer covariates or adjustments) and then use the starting values from this simpler model for the corresponding parameters.
Another alternative to obtain starting values is to fit the model (or some
submodel) using Distance for Windows. Note that Distance reports the scale
parameter (or intercept in a covariate model) on the exponential scale, so
one must log
this before supplying it to ddf
.
Bounds
One can change the upper and lower bounds for the dsmodel parameters. These specify the largest and smallest values individual parameters can be. By placing these constraints on the parameters, it is possible to "temper" the optimisation problem, making fitting possible.
Again, one uses the control
list, the elements upperbounds
and
lowerbounds
. In this case, each of upperbounds
and
lowerbounds
are vectors, which one can think of as each of the
vectors shape
, scale
and adjustment
from the "Initial
values" section above, concatenated in that order. If one does not occur
(e.g. no shape parameter) then it is simple omitted from the vector.
Author(s)
David L. Miller <dave@ninepointeightone.net>