bootCI {fitPS} | R Documentation |
Bootstrap confidence intervals or regions
Description
Use boostrapping to generate confidence intervals, or confidence regions in the case of the zero-inflated model.
Usage
bootCI(x, ...)
## Default S3 method:
bootCI(
x,
level = 0.95,
B = 2000,
model = c("zeta", "ziz"),
returnBootValues = FALSE,
silent = FALSE,
plot = FALSE,
parallel = TRUE,
progressBar = FALSE,
pbopts = list(type = "txt"),
...
)
## S3 method for class 'psData'
bootCI(x, ...)
## S3 method for class 'psFit'
bootCI(x, ...)
Arguments
x |
a object either of class |
... |
other arguments. |
level |
the confidence level required—restricted to [0.75, 1). This may be a vector, in which case multiple intervals, or confidence regions will be returned. |
B |
the number of bootstrap samples to take. |
model |
which model to fit to the data, either |
returnBootValues |
if |
silent |
if |
plot |
if |
parallel |
if |
progressBar |
if |
pbopts |
a list of arguments for the |
Details
This function uses bootstrapping to compute a confidence interval for
the shape parameter in the case of the zeta model and a confidence region in
the case of the zero-inflated zeta model. A smoothed bootstrap approach is
taken rather than a simple percentile method. The kernel density estimation
is performed by the ks
package using a smoothed cross-validated
bandwidth selection procedure.
Value
If returnBootVals == TRUE
then the results are returned in a
list with elements named ci
and bootVals
for the zeta model
and confRegion
and bootVals
for the zero-inflated zeta model.
The structure of ci
and confregion
is described below. If
model == "zeta"
, then either a vector
or a data.frame
with elements/columns named "lower"
and "upper"
representing
the lower and upper bounds of the confidence interval(s). Multiple bounds
are returned in a data.frame
when level
has more than one
value. If model == "ziz
"
, then a list with length equal to the
length of level
is returned. The name of each element in the list is
the level with
list has a single element named "95%"
. It is possible for there to
be multiple contours for the confidence region for a given level
. If
there is only one contour for each value of level
, then each element
of the list consists of a list
with elements named pi
and
shape
which specify the coordinates of the contour(s) for that level.
There is a third element named level
which gives the height of the
kernel density estimate at that contour. If there are multiple contours for
a given value of level
then each list element is a list of lists with
the structure given above (level
, pi
, and shape
). NOTE:
it is quite possible that there are multiple contours for a given height. If
you want a way of thinking about this consider a mountain range with two
mountains of equal height. If you draw the contours for (almost) any
elevation, then you would expect to capture a region from each mountain.
Methods (by class)
-
bootCI(default)
: Bootstrap confidence intervals or regions -
bootCI(psData)
: Bootstrap confidence intervals or regions -
bootCI(psFit)
: Bootstrap confidence intervals or regions
Examples
## Not run:
data(Psurveys)
roux = Psurveys$roux
confRegion = bootCI(roux, model = "ziz", parallel = FALSE, plot = TRUE)
## This will not work unless you have the sp package installed
## Count how many of the points lie within the 95% confidence region
lapply(confRegion, function(cr){
table(sp::point.in.polygon(fit$pi,fit$shape, cr$pi, cr$shape))
. })
## End(Not run)