This function extends the maximum entropy bootstrap procedure
implemented in 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))
A matrix containing by columns
the bootstrapped replicated of the original data x
.
vector of data, ts
object.
number of replicates to generate.
block size.
logical. If TRUE the ensemble is forced to satisfy the central limit theorem.
See force.clt
.
directions for trend within a block of data is chosen randomly with the user's choice
limited by the range of values given by myseq. For example, 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.
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:
Choose block size 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.
Regress each block having m observations as subsets of x
on the set
\(\tau = 1, 2,..., m\), and store the intercept \(b0\),
the slope \(b1\) of \(\tau\) and the residuals \(r\).
Note that the positive (negative) sign of the slope \(b1\) in this regression determines the up (down) direction of the time series in that block. Hence the next step of the algorithm replaces \(b1\) by \(B1 = b1 * w\), defined by a randomly chosen weight \(w in (-1, 0, 1)\). For example, when the random choice yields \(w = -1\), the sign of \(b1\) is reversed. Our weighting independently injects some limited flexibility to the directions of values block segments of the original time series.
Reconstruct all time series blocks as: \(b0 + b1 * w * \tau + r\), by adding back the residual \(r\) of the regression on \(\tau\).
The next step applies the function 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.
Sequentially join the \(J\) replicates of all \(k\) blocks or subsets together.
Vinod, H.D. (2012), Constructing Scenarios of Time Heterogeneous Series for Stress Testing, Available at SSRN: https://www.ssrn.com/abstract=1987879.
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