R: Maximum Likelihood Model of mixtures of 2 or 3 Poisson...

fitMLEbouts,numeric-method {diveMove} | R Documentation

## Maximum Likelihood Model of mixtures of 2 or 3 Poisson Processes

### Description

Functions to model a mixture of 2 random Poisson processes to identify bouts of behaviour. This follows Langton et al. (1995).

### Usage

    ## S4 method for signature 'numeric'
    fitMLEbouts(obj, start, optim_opts0 = NULL, optim_opts1 = NULL)

    ## S4 method for signature 'Bouts'
    fitMLEbouts(obj, start, optim_opts0 = NULL, optim_opts1 = NULL)

### Arguments

`obj` | Object of class `Bouts`.
`start` | passed to `mle`. A row- and column-named (2,N) matrix, as returned by `boutinit`.
`optim_opts0` | named list of optional arguments passed to `mle` for fitting the first model with transformed parameters.
`optim_opts1` | named list of optional arguments passed to `mle` for fitting the second model with parameters retrieved from the first model, untransformed to original scale.

### Details

Mixtures of 2 or 3 Poisson processes are supported. Even in this relatively simple case, it is very important to provide good starting values for the parameters.

One useful strategy to get good starting parameter values is to proceed in 4 steps. First, fit a broken stick model to the log frequencies of binned data (see `boutinit`), to obtain estimates of 4 parameters in a 2-process model (Sibly et al. 1990), or 6 in a 3-process model. Second, calculate parameter(s) p from the alpha parameters obtained from the broken stick model, to get tentative initial values as in Langton et al. (1995). Third, obtain MLE estimates for these parameters, but using a reparameterized version of the -log L2 function. Lastly, obtain the final MLE estimates for the 3 parameters by using the estimates from step 3, un-transformed back to their original scales, maximizing the original parameterization of the -log L2 function.

`boutinit` can be used to perform step 1. Calculation of the mixing parameters p in step 2 is trivial from these estimates. Function `boutsMLEll.chooser` defines a reparameterized version of the -log L2 function given by Langton et al. (1995), so can be used for step 3. This uses a logit (see `logit`) transformation of the mixing parameter p, and log transformations for both density parameters lambda1 and lambda2. Function `boutsMLEll.chooser` can be used again to define the -log L2 function corresponding to the un-transformed model for step 4.

`fitMLEbouts` is the function performing the main job of maximizing the -log L2 functions, and is essentially a wrapper around `mle`. It only takes the -log L2 function, a list of starting values, and the variable to be modelled, all of which are passed to `mle` for optimization. Additionally, any other arguments are also passed to `mle`, hence great control is provided for fitting any of the -log L2 functions.

In practice, step 3 does not pose major problems using the reparameterized -log L2 function, but it might be useful to use method “L-BFGS-B” with appropriate lower and upper bounds. Step 4 can be a bit more problematic, because the parameters are usually on very different scales and there can be multiple minima. Therefore, it is almost always the rule to use method “L-BFGS-B”, again bounding the parameter search, as well as passing a `control` list with proper `parscale` for controlling the optimization. See `Note` below for useful constraints which can be tried.

### Value

An object of class `mle`.

### Methods (by class)

- `numeric`: Fit model via MLE on numeric vector.

- `Bouts`: Fit model via MLE on `Bouts` object.

### Note

In the case of a mixture of 2 Poisson processes, useful values for lower bounds for the transformed negative log likelihood reparameterization are `c(-2, -5, -10)`. For the un-transformed parameterization, useful lower bounds are `rep(1e-08, 3)`. A useful parscale argument for the latter is `c(1, 0.1, 0.01)`. However, I have only tested this for cases of diving behaviour in pinnipeds, so these suggested values may not be useful in other cases.

The lambdas can be very small for some data, particularly `lambda2`, so the default `ndeps` in `optim` can be so large as to push the search outside the bounds given. To avoid this problem, provide a smaller `ndeps` value.

### Author(s)

Sebastian P. Luque spluque@gmail.com

### References

Langton, S.; Collett, D. and Sibly, R. (1995) Splitting behaviour into bouts; a maximum likelihood approach. Behaviour 132, 9-10.

Luque, S.P. and Guinet, C. (2007) A maximum likelihood approach for identifying dive bouts improves accuracy, precision, and objectivity. Behaviour, 144, 1315-1332.

Sibly, R.; Nott, H. and Fletcher, D. (1990) Splitting behaviour into bouts. Animal Behaviour 39, 63-69.

### Examples

    ## Run example to retrieve random samples for two- and three-process
    ## Poisson mixtures with known parameters as 'Bouts' objects
    ## ('xbouts2', and 'xbouts3'), as well as starting values from
    ## broken-stick model ('startval2' and 'startval3')
    utils::example("boutinit", package="diveMove", ask=FALSE)

    ## 2-process
    opts0 <- list(method="L-BFGS-B", lower=c(-2, -5, -10))
    opts1 <- list(method="L-BFGS-B", lower=c(1e-1, 1e-3, 1e-6))
    bouts2.fit <- fitMLEbouts(xbouts2, start=startval2, optim_opts0=opts0,
                              optim_opts1=opts1)
    plotBouts(bouts2.fit, xbouts2)

    ## 3-process
    opts0 <- list(method="L-BFGS-B", lower=c(-5, -5, -6, -8, -12))
    ## We know 0 < p < 1, and can provide bounds for lambdas within an
    ## order of magnitude for a rough box constraint.
    lo <- c(9e-2, 9e-2, 2e-3, 1e-3, 1e-5)
    hi <- c(9e-1, 9.9e-1, 2e-1, 9e-2, 5e-3)
    ## Important to set the step size to avoid running below zero for
    ## the last lambda.
    ndeps <- c(1e-3, 1e-3, 1e-3, 1e-3, 1e-5)
    opts1 <- list(method="L-BFGS-B", lower=lo, upper=hi,
                  control=list(ndeps=ndeps))
    bout3.fit <- fitMLEbouts(xbouts3, start=startval3, optim_opts0=opts0,
                             optim_opts1=opts1)
    bec(bout3.fit)
    plotBoutsCDF(bout3.fit, xbouts3)

[Package diveMove version 1.6.0 Index]