Generates bootstrap estimations of an MCD.
Usage
# S4 method for class 'MeanDate'
bootstrap(
object,
n = 1000,
f = NULL,
level = 0.95,
interval = c("basic", "normal", "percentiles"),
seed = NULL,
calendar = get_calendar()
)
Arguments
- object
- n
A non-negative
integer
specifying the number of bootstrap replications.- f
A
function
that takes a single numeric vector (the result of the resampling procedure) as argument.- level
A length-one
numeric
vector giving the confidence level. Must be a single number between \(0\) and \(1\). Only used iff
isNULL
.- interval
A
character
string giving the type of confidence interval to be returned. It must be one "basic
" (the default), "normal
" or "percentiles
" (seearkhe::confidence_bootstrap()
). Any unambiguous substring can be given. Only used iff
isNULL
.- seed
An object specifying if and how the random number generator should be initialized (see
stats::simulate()
).- calendar
An
aion::TimeScale
object specifying the target calendar (seeaion::calendar()
).
Value
If f
is NULL
, bootstrap()
returns a data.frame
with the following
elements (else, returns the result of f
applied to the n
resampled
values) :
original
The observed value.
mean
The bootstrap estimate of mean.
bias
The bootstrap estimate of bias.
error
The boostrap estimate of standard error.
lower
The lower limit of the bootstrap confidence interval at
level
.upper
The upper limit of the bootstrap confidence interval at
level
.
See also
Other resampling methods:
bootstrap.EventDate
,
jackknife.EventDate
,
jackknife.MeanDate
Examples
## Data from Peeples and Schachner 2012
data("zuni", package = "folio")
## Set the start and end dates for each ceramic type
dates <- list(
LINO = c(600, 875), KIAT = c(850, 950), RED = c(900, 1050),
GALL = c(1025, 1125), ESC = c(1050, 1150), PUBW = c(1050, 1150),
RES = c(1000, 1200), TULA = c(1175, 1300), PINE = c(1275, 1350),
PUBR = c(1000, 1200), WING = c(1100, 1200), WIPO = c(1125, 1225),
SJ = c(1200, 1300), LSJ = c(1250, 1300), SPR = c(1250, 1300),
PINER = c(1275, 1325), HESH = c(1275, 1450), KWAK = c(1275, 1450)
)
## Calculate date midpoints
mid <- vapply(X = dates, FUN = mean, FUN.VALUE = numeric(1))
## Calculate MCD
(mc_dates <- mcd(zuni[100:125, ], dates = mid))
#> 26 x 18 x 1 time series observed between 757.291 CE and 1259.38 CE
## Get MCD in years CE
time(mc_dates, calendar = CE())
#> [1] 757.2912 796.6659 797.4991 952.5855 996.2952 1016.0738 1027.5011
#> [8] 1059.5249 1073.6597 1075.5213 1089.5820 1092.8564 1100.0000 1127.7799
#> [15] 1137.1101 1200.0017 1204.3868 1207.1436 1219.4454 1227.3745 1235.4176
#> [22] 1237.5000 1238.8896 1253.1241 1256.2502 1259.3757
## Bootstrap resampling
boot <- bootstrap(mc_dates, n = 30)
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
#> Warning: Extreme order statistics used as endpoints.
head(boot)
#> original mean bias error lower upper
#> LZ0789 757.2917 757.6215 0.3298611 13.62395 717.7083 777.0833
#> LZ0783 796.6667 795.9444 -0.7222222 33.45576 748.3333 855.8333
#> LZ0782 797.5000 794.4706 -3.0294118 11.30521 775.0000 820.8824
#> LZ0778 952.5862 965.6322 13.0459770 32.62280 850.4310 1006.0345
#> LZ0777 996.2963 998.2253 1.9290123 20.59349 962.0370 1035.8796
#> LZ0776 1016.0714 1016.2202 0.1488095 42.04516 923.2143 1122.3214
## Jackknife resampling
jack <- jackknife(mc_dates)
head(jack)
#> original mean bias error
#> LZ0789 757.2917 768.2870 186.921296 207.5535
#> LZ0783 796.6667 806.9974 175.621693 228.0861
#> LZ0782 797.5000 804.1715 113.415558 169.0563
#> LZ0778 952.5862 954.5205 32.882529 138.6064
#> LZ0777 996.2963 996.6640 6.251785 111.0144
#> LZ0776 1016.0714 1017.1652 18.594831 72.6602
## Plot
plot(mc_dates, decreasing = FALSE)
## Add bootstrap confidence intervals
segments(x0 = boot$lower, y0 = seq_len(nrow(boot)),
x1 = boot$upper, y1 = seq_len(nrow(boot)))