
Last chance! 50% off unlimited learning
Sale ends in
Simple Monte-Carlo goodness-of-fit tests for full-likelihood SECR models. The approach is to calculate a statistic from either the raw data or a fitted model, and to relate this to the distribution of the statistic under the original fitted model. The distribution is estimated by simulating data from the model, and possibly re-fitting the model to each simulated dataset.
The suitability of different test statistics has yet to be assessed.
secr.test(object, nsim = 99, statfn, fit = FALSE, seed =
NULL, ncores = 1, tracelevel = 1)
a fitted secr model
integer number of replicates
function to compute a numeric vector of one or more statistics from a single-session `capthist' object or from a fitted model (see Details)
logical; if TRUE the model is re-fitted to each simulated dataset
either NULL or an integer that will be used in a call to set.seed
integer number of cores available for parallel processing
see sim.secr
An object of class c('secrtest','list')
with components:
as input
as input
as input
as input
as input
list comprising the simulated values, the observed value(s), and estimated probabilities
For multi-session input when fit = FALSE, `output' is a list in which each session provides one component.
Print and plot methods are provided for `secrtest' objects.
The test statistic(s) may be computed either on a dataset or on a
fitted model, as determined by the argument fit
. The single
argument expected by statfn
should be either a `capthist' object
(fit = FALSE
) or an `secr' object (fit = TRUE
).
The default statistic when fit = FALSE
is the proportion of
individuals observed on only one occasion, which is equivalent to
statfn = function(CH) c(f1 = sum(apply(abs(CH) > 0,1,sum) == 1) /
nrow(CH))
. Repeat detections on one occasion at the same or different
detectors are not counted. The default statistic is therefore not
appropriate for some data, specifically from `count' or `polygon'
detectors with few occasions or only one.
The default statistic when fit = TRUE
is the deviance divided by
the residual degrees of freedom (i.e., statfn = function(object)
c(devdf = deviance(object) / df.residual(object))
).
The reported probability (p) is the rank of the observed value in the
vector combining the observed value and simulated values, divided by
(nsim + 1). Ranks are computed with rank
using the default
ties.method = "average"
.
Simulations take account of the usage attribute of detectors in the original capthist object, given that usage was defined and ignoreusage was not set.
statfn
may return a vector of statistics for each observed or
simulated dataset or model: then the value of each statistic will be
calculated for every simulated dataset, and summarised. If fit =
TRUE
the vector of statistics may include both those computed on the
raw data (object$capthist) and the fitted model.
print.secrtest
,
plot.secrtest
,
simulate.secr
,
sim.secr
,
deviance.secr
# NOT RUN {
# }
# NOT RUN {
secr.test(secrdemo.0, nsim = 99)
secr.test(ovenbird.model.1, nsim = 20)
## example combining raw data summary and model fit
## assumes single-session
bothfn <- function(object) {
CH <- object$capthist
f1 <- sum(apply(abs(CH) > 0, 1, sum) == 1) / nrow(CH)
devdf <- deviance(object) / df.residual(object)
c(f1 = f1, devdf = devdf)
}
test <- secr.test (secrdemo.0, nsim = 19, statfn = bothfn, fit = TRUE)
test
plot(test, main = '')
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab