# bouts3NLS: Fit mixture of 3 Poisson Processes to Log Frequency data In diveMove: Dive analysis and calibration

## Description

Functions to model a mixture of 3 random Poisson processes to histogram-like data of log frequency vs interval mid points. This follows Sibly et al. (1990) method, adapted for a three-process model by Berdoy (1993).

## Usage

 ```1 2 3 4``` ```bouts3.nlsFUN(x, a1, lambda1, a2, lambda2, a3, lambda3) bouts3.nls(lnfreq, start, maxiter) bouts3.nlsBEC(fit) plotBouts3.nls(fit, lnfreq, bec.lty, ...) ```

## Arguments

 `x` numeric vector with values to model. `a1, lambda1, a2, lambda2, a3, lambda3` numeric: parameters from the mixture of Poisson processes. `lnfreq` `data.frame` with named components lnfreq (log frequencies) and corresponding x (mid points of histogram bins). `start, maxiter` Arguments passed to `nls`. `fit` nls object. `bec.lty` Line type specification for drawing the BEC reference line. `...` Arguments passed to `plot.default`.

## Details

`bouts3.nlsFUN` is the function object defining the nonlinear least-squares relationship in the model. It is not meant to be used directly, but is used internally by `bouts3.nls`.

`bouts3.nls` fits the nonlinear least-squares model itself.

`bouts3.nlsBEC` calculates the BEC from a list object, as the one that is returned by `nls`, representing a fit of the model. `plotBouts3.nls` plots such an object.

## Value

`bouts3.nlsFUN` returns a numeric vector evaluating the mixture of 3 Poisson process.

`bouts3.nls` returns an nls object resulting from fitting this model to data.

`bouts3.nlsBEC` returns a number corresponding to the bout ending criterion derived from the model.

`plotBouts3.nls` plots the fitted model with the corresponding data.

## Author(s)

Sebastian P. Luque [email protected]

## References

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

Berdoy, M. (1993) Defining bouts of behaviour: a three-process model. Animal Behaviour 46, 387-396.

`bouts.mle` for a better approach; `boutfreqs`; `boutinit`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28``` ```## Using the Example from '?diveStats': utils::example("diveStats", package="diveMove", ask=FALSE, echo=FALSE) ## Postdive durations postdives <- tdrX.tab\$postdive.dur postdives.diff <- abs(diff(postdives)) ## Remove isolated dives postdives.diff <- postdives.diff[postdives.diff < 4000] ## Construct histogram lnfreq <- boutfreqs(postdives.diff, bw=0.1, plot=FALSE) startval <- boutinit(lnfreq, c(50, 400)) ## Drop names by wrapping around as.vector() startval.l <- list(a1=as.vector(startval[]["a"]), lambda1=as.vector(startval[]["lambda"]), a2=as.vector(startval[]["a"]), lambda2=as.vector(startval[]["lambda"]), a3=as.vector(startval[]["a"]), lambda3=as.vector(startval[]["lambda"])) ## Fit the 3 process model bout.fit <- bouts3.nls(lnfreq, start=startval.l, maxiter=500) summary(bout.fit) plotBouts(bout.fit) ## Estimated BEC bec3(bout.fit) ```