# boot_spec: Function that computes boostrapped confidence intervals for... In timesboot: Bootstrap computations for time series objects

## Description

The function resamples a time series object using phase scramble bootstrap and returns the average,lower and upper confidence bounds.

## Usage

 ```1 2``` ```boot_spec(series, replic = 5000, spansa = c(11, 21), plot = TRUE, de_trend = FALSE, alpha = 0.05) ```

## Arguments

 `series` A time series object `replic` The amount of replications used in the bootstrap step `spansa` The spans for smoothing the spectrum `plot` TRUE,FALSE. Whether plotting is desired. Default is TRUE. `de_trend` TRUE,FALSE. Should de-trending be applied to the series.Default is FALSE `alpha` The alpha used in the construction of the CI. Default is 0.05

## Value

 `average` The average value for each frequency `upper` The upper value for each frequency `lower` The lower value for each frequency

## 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_spec(AirPassengers,replic=1000,alpha=0.05) function (series, replic = 5000, spansa = c(11, 21), plot = TRUE, de_trend = FALSE, alpha = 0.05) { if (is.ts(series) == TRUE) { library(boot) kas = tsboot(series, redraw, p = spansa, detrend = de_trend, replic, sim = "scramble") span1 = spansa span2 = spansa quantiles = matrix(0, length(kas\$t[1, ]), 3) Xvalues = spec.pgram(series, spans = c(span1, span2), plot = FALSE) for (i in 1: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) } if (plot == TRUE) { maximus = max(quantiles[, 3]) plot(Xvalues\$freq, quantiles[, 1], type = "l", col = "blue", ylim = c(0, maximus * 2), main = "Bootstraped Periodogram", ylab = "periodogram", lwd = 1, xlab = "frequency") polygon(c(Xvalues\$freq, rev(Xvalues\$freq)), c(quantiles[, 1], rev(quantiles[, 2])), col = "skyblue") lines(Xvalues\$freq, quantiles[, 3], type = "o", col = "black", pch = 20) } lix = list(freq = Xvalues\$freq, upper = quantiles[, 2], lower = quantiles[, 1], mean = quantiles[, 3]) return(lix) } else { return("Object is not a time-series") } } ```

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