moving.fit {openCR} | R Documentation |
Moving Window Functions
Description
Apply a function to successive multi-session windows from a capthist object. The default function is openCR.fit
, but any function may be used whose first argument accepts a capthist object.
Usage
moving.fit (..., width = 3, centres = NULL, filestem = NULL,
trace = FALSE, FUN = openCR.fit)
extractFocal (ocrlist, ...)
Arguments
... |
named arguments passed to |
width |
integer; moving window width (number of primary sessions) |
centres |
integer; central sessions of windows to consider |
filestem |
character or NULL; stem used to form filenames for optional intermediate output |
trace |
logical; if TRUE a status message is given at each call of FUN |
FUN |
function to be applied to successive capthist objects |
ocrlist |
openCRlist object returned by |
Details
moving.fit
applies FUN
to successive multi-session subsets
of the data in the capthist
argument. width
should be an odd integer.
centres
may be used to restrict the range of windows considered;
the default is to use all complete windows (width%/%2 + 1)...).
If a filestem
is specified then each result is output to a file that may be loaded with
load
. This is useful if fitting takes a long time and analyses
may be terminated before completion.
extractFocal
returns the focal-session (central) estimates from a moving.fit
with FUN = openCR.fit
. The ... argument is passed to predict.openCR
;
it may be used, for example, to choose a different alpha level for confidence intervals.
extractFocal
is untested for complex models (e.g. finite mixtures).
Value
A list in which each component is the output from FUN applied to one subset. The window width is saved as attribute ‘width’.
See Also
Examples
## number of individuals detected
moving.fit(capthist = OVpossumCH, FUN = nrow)
## Not run:
## if package R2ucare installed
if (requireNamespace("R2ucare"))
moving.fit(capthist = OVpossumCH, FUN = ucare.cjs, width = 5, tests = "overall_CJS")
## using default FUN = openCR.fit
mf1 <- moving.fit(capthist = OVpossumCH, type = 'JSSAfCL',
model = list(p~t, phi~t))
lapply(mf1, predict)
extractFocal(mf1)
msk <- make.mask(traps(OVpossumCH[[1]]), nx = 32)
mf2 <- moving.fit(capthist = OVpossumCH, mask = msk, type = 'JSSAsecrfCL')
extractFocal(mf2)
## End(Not run)