Variance estimation via parametric moving block bootstrap
Source:R/dsm_var_movblk.R
dsm_var_movblk.RdEstimate the variance in abundance over an area using a moving block bootstrap. Two procedures are implemented, one incorporating detection function uncertainty, one not.
Usage
dsm_var_movblk(
dsm.object,
pred.data,
n.boot,
block.size,
off.set,
ds.uncertainty = FALSE,
samp.unit.name = "Transect.Label",
progress.file = NULL,
bs.file = NULL,
bar = TRUE
)Arguments
- dsm.object
object returned from
dsm.- pred.data
either: a single prediction grid or list of prediction grids. Each grid should be a
data.framewith the same columns as the original data.- n.boot
number of bootstrap resamples.
- block.size
number of segments in each block.
- off.set
a a vector or list of vectors with as many elements as there are in
pred.data. Each vector is as long as the number of rows in the corresponding element ofpred.data. These give the area associated with each prediction cell. If a single number is supplied it will be replicated for the length ofpred.data.- ds.uncertainty
incorporate uncertainty in the detection function? See Details, below. Note that this feature is EXPERIMENTAL at the moment.
- samp.unit.name
name sampling unit to resample (default 'Transect.Label').
- progress.file
path to a file to be used (usually by Distance) to generate a progress bar (default
NULL– no file written).- bs.file
path to a file to store each bootstrap round. This stores all of the bootstrap results rather than just the summaries, enabling outliers to be detected and removed. (Default
NULL).- bar
should a progress bar be printed to screen? (Default
TRUE).
Details
Setting ds.uncertainty=TRUE will incorporate detection function
uncertainty directly into the bootstrap. This is done by generating
observations from the fitted detection function and then re-fitting a new
detection function (of the same form), then calculating a new effective
strip width. Rejection sampling is used to generate the observations
(except in the half-normal case) so the procedure can be rather slow. Note
that this is currently not supported with covariates in the detection
function.
Setting ds.uncertainty=FALSE will incorporate detection function
uncertainty using the delta method. This assumes that the detection
function and the spatial model are INDEPENDENT. This is probably not
reasonable.
Examples
if (FALSE) { # \dontrun{
library(Distance)
library(dsm)
# load the Gulf of Mexico dolphin data (see ?mexdolphins)
data(mexdolphins)
# fit a detection function and look at the summary
hr.model <- ds(distdata, truncation=6000,
key = "hr", adjustment = NULL)
summary(hr.model)
# fit a simple smooth of x and y
mod1 <- dsm(count~s(x, y), hr.model, segdata, obsdata)
summary(mod1)
# calculate the variance by 500 moving block bootstraps
mod1.movblk <- dsm_var_movblk(mod1, preddata, n.boot = 500,
block.size = 3, samp.unit.name = "Transect.Label",
off.set = preddata$area,
bar = TRUE, bs.file = "mexico-bs.csv", ds.uncertainty = TRUE)
} # }