meboot
to allow for for a flexible trend up, flat or down.flexMeboot (x, reps = 9, segment = 5, forc = FALSE, myseq = seq(-1, 1, by = 1))x.flexMeboot uses non-overlapping blocks having only m observations.
A trend $a + bt$ is replaced by $a + Bt$,
where B = sample(myseq) * b.Its steps are as follows:
segmentdenoted here as$m$(default equal to$m=5$)
and divide the original time seriesxof length$T$into$k = floor(T/m)$blocks or subsets. Note that when$T/m$is not an integer the$k$-th block will have a few more than$m$items. Hence let us denote the number of observations in each block as$m$which equals$m$for most blocks, except the$k$-th.xon the set$\tau = 1, 2,..., m$, and store the intercept$b0$,
the slope$b1$of$\tau$and the residuals$r$.mebootto each
block of time serie-now having a modified trend-and create a large
number,$J$, of resampled time series for each of the$k$blocks.meboot.set.seed(235)
myseq <- seq(-1, 1, by = 0.5)
xx <- flexMeboot(x = AirPassengers, myseq = myseq, reps = 3)
matplot(cbind(AirPassengers, xx), type = "l")Run the code above in your browser using DataLab