rollingWindows {iForecast} | R Documentation |
Rolling timeframe for time series anaysis
Description
It extracts time stamp from a timeSeries object and separates the time into in-sample training and out-of-sample validation ranges.
Usage
rollingWindows(x,estimation="18m",by = "6m")
Arguments
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). |
Details
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.
Value
window |
The time labels of from and to |
.
Author(s)
Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.
Examples
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.