Learn R Programming

diveMove (version 0.8.3)

bouts2NLS: Fit mixture of 2 Poisson Processes to Log Frequency data

Description

Functions to model a mixture of 2 random Poisson processes to histogram-like data of log frequency vs interval mid points. This follows Sibly et al. (1990) method.

Usage

bouts2.nlsFUN(x, a1, lambda1, a2, lambda2)
bouts2.nls(lnfreq, start, maxiter)
bouts2.nlsBEC(fit)
plotBouts2.nls(fit, lnfreq, bec.lty, ...)

Arguments

x
Numeric vector with values to model.
a1, lambda1, a2, lambda2
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.

Value

  • bouts2.nlsFUN returns a numeric vector evaluating the mixture of 2 Poisson process.

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

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

    plotBouts2.nls plots the fitted model with the corresponding data.

References

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

See Also

bouts.mle for a better approach.

Examples

Run this code
data(divesSummary)
## Postdive durations
postdives <- divesSummary$postdive.dur[divesSummary$trip.no == 2]
postdives.diff <- abs(diff(postdives))
## Remove isolated dives
postdives.diff <- postdives.diff[postdives.diff < 2000]

## Construct histogram
lnfreq <- boutfreqs(postdives.diff, bw=0.1, plot=FALSE)
startval <- boutinit(lnfreq, 50)

## Fit the 2 process model
bout.fit1 <- bouts2.nls(lnfreq, start=startval, maxiter=500)
summary(bout.fit1)
plotBouts(bout.fit1)

## Estimated BEC
bec2(bout.fit1)

Run the code above in your browser using DataLab