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))ts object.force.clt.myseq=seq(-1,1,by=0.5)
provides five options for direction changes. If the user specifies any single number
instead of a sequence, (e.g., myseq=1) then flexMeboot will not change the directions
of trends at all, but will modify the original meboot function to resample separately
within several non-overlapping blocks, before joining them into resampled time series.
This may be desirable for long series and for some applications.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:
segment denoted here as $m$
(default equal to $m=5$)
and divide the original time series x of 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.
x on the set
$\tau = 1, 2,..., m$, and store the intercept $b0$,
the slope $b1$ of $\tau$ and the residuals $r$.
meboot to 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