I got this error message about my code:
Error in statistic(data, original, ...) : unused argument (original)
I need to run a bootstrap method to estimate pvalue in a periodogram. My timeseries was created by ts()
function containing data of 365 days.
First, I defined a function:
periodogram_fun <- function(x) {
TSA::periodogram(x)$spec
}
Following, I tried to run the boot:
bootstrapped_periodograms <- boot(tsdata, periodogram_fun, R=1000)
and got the error message persists: Error in statistic(data, original, ...) : unused argument (original)
Please, I need to solve this questions to run my seasonality data
This should do it:
library(TSA)
library(boot)
periodogram_fun <- function(x, ind) {
periodogram(ts(x[ind], start=1, end=365), plot=FALSE)$spec
}
bootstrapped_periodograms <- boot(tsdata, periodogram_fun, R=1000)
The function you're bootstrapping has to have two arguments - the first being the data and the second being the bootstrapped observation numbers. This assumes that you just want a nonparametric bootstrap where you're randomly resampling the values in your time-series and creating a new time-series out of those 365 randomly re-sampled values.