rollingWindows | R Documentation |
It extracts time stamp from a timeSeries object and separates the time into in-sample training and out-of-sample validation ranges.
rollingWindows(x,estimation="18m",by = "6m")
x |
The time series matrix (vector) with |
estimation |
The range of insample estimation period, the default is 18 months(18m), where the k-fold cross-section is performed. Week and day are also supported (see example). |
by |
The range of out-of-sample validation/testing period, the default is 6 months(6m).Week and day are also supported (see example). |
This function is similar to the backtesting framework in portfolio analysis. Rolling windows fixes the origin and the training sample grows over time, moving windows can be achieved by placing window() on dependent variable at each iteration.
window |
The time labels of from and to |
.
Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.
data(macrodata)
y=macrodata[,1,drop=FALSE]
timeframe=rollingWindows(y,estimation="300m",by="6m")
#estimation="300m", because macrodata is monthly
FROM=timeframe$from
TO=timeframe$to
data(ES_Daily)
y=ES_Daily[,1,drop=FALSE]
timeframe=rollingWindows(y,estimation ="60w",by="1w")
#60 weeks as estimation windowand move by 1 week.
FROM=timeframe$from
TO=timeframe$to
y=ES_Daily[,1,drop=FALSE]
timeframe=rollingWindows(y,estimation ="250d",by="1d")
#250-day as estimation window and move by 1 days.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.