# boot_autocov: A function that computes the bootstrapped autocovariances for... In timesboot: Bootstrap computations for time series objects

## Description

The function resamples the time series object and returns the average , upper, and lower bounds for the autocovariances for each lag.

## Usage

 `1` ```boot_autocov(series, replic = 5000, plot = TRUE, alpha = 0.05) ```

## Arguments

 `series` A time series object `replic` The amount of boostrap replicates `plot` TRUE,FALSE indicating whether the plot is desired `alpha` the alpha needed for the intervals

## Value

 `average` The average ACF for each lag `lower` The ACF lower quantile for each lag `upper` The ACF upper quantile for each lag

## Author(s)

Francisco Juretig

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38``` ```boot_autocov(AirPassengers,replic=1000,alpha=0.05) function (series, replic = 5000, plot = TRUE, alpha = 0.05) { if (is.ts(series) == TRUE) { library(boot) kas = tsboot(series, statistic, R = replic, sim = "scramble") quantiles = matrix(0, length(kas\$t[1, ]), 3) for (i in 2:length(kas\$t[1, ])) { cp = kas\$t[, i] quantiles[i, 1] = quantile(cp, alpha) quantiles[i, 2] = quantile(cp, 1 - alpha/2) quantiles[i, 3] = mean(cp) } quantiles = quantiles[-1, ] if (plot == TRUE) { par(mfrow = c(1, 2)) x = seq(1, length(quantiles[, 1]), 1)/frequency(series) plot(x, quantiles[, 1], type = "l", col = "blue", main = "Bootstraped Correlogram", ylab = "value", lwd = 1, xlab = "lag") polygon(c(x, rev(x)), c(quantiles[, 1], rev(quantiles[, 2])), col = "skyblue") lines(x, quantiles[, 3], type = "o", col = "black", pch = 20) abline(a = 0, b = 0) plot(acf(series, plot = FALSE), main = "Asymptotic Correlogram", ylim = c(-1, 1)) } lista = list(average = quantiles[, 1], upper = quantiles[, 2], lower = quantiles[, 3]) return(lista) } else { return("Object is not a time-series") } } ```

timesboot documentation built on May 2, 2019, 2:37 p.m.