PortfolioAnalytics Training and Rolling Window Lengths Use Return Periods
Summary
The document clarifies how PortfolioAnalytics interprets the `training_period` and `rolling_window` settings in rebalancing optimization. Both are integer counts of observations, measured in the same time units as the returns series. Thus, their effective meaning depends on the input frequency: a count refers to daily observations for daily data, or monthly observations for monthly data.
The `rebalance_on` setting is separate and specifies a calendar schedule such as months or quarters. The example combines monthly rebalancing with a training length of 60 periods and a rolling window of 48 periods, interpreting these as five years and four years when the returns data are monthly. These durations change if the series frequency changes. The explanation is tied to the package documentation and does not describe the optimization method itself or how to choose suitable window lengths.
Key ideas
- Training and rolling window arguments count observations in the returns series.
- The time represented by each count depends on the data frequency.
- The rebalance schedule is configured separately from the window lengths.
- Window values that represent years for monthly data represent a different span at other frequencies.
Tags
Full text
# PortfolioAnalytics: What is the training_period and rolling_window "type" in optimize.portfolio.rebalancing?
# PortfolioAnalytics: What is the training_period and rolling_window "type" in optimize.portfolio.rebalancing?
In R-package PortfolioAnalytics, what is the unit of the `training_period` and `rolling_window` ? is it the just data points ? or is it related to the `rebalance_on` period?
Edit/precisions: example: if I put `training_period = 50` what is the unit of that `50`? Turns out, it's `50` time periods, the same as the returns series.
## Answer by amdopt (score 1, accepted)
https://quant.stackexchange.com/a/39456
On pages 83-85 in the link below:
> training_period: an integer of the number of periods to use as a training data in the front of the returns. data rolling_window: an integer of the width (i.e., number of periods) of the rolling window, the default of NULL will run the optimization using the data from inception.
So the "type" is integer. The "unit" depends on what data you have...minutes, hours, days, months, quarters, years, etc. That period is the "unit" you are asking about which will also be of "type" integer and will be the same unit as your time series. The other input you ask about, "rebalance_on," is a string input ("Months," "Quarters," etc.). Below is taken directly from page 85 in the link below as well. The code snippet would optimize for ROI via monthly rebalancing with five year training period and 4-year rolling window.
```
bt.opt2 <- optimize.portfolio.rebalancing(R, portf,
optimize_method="ROI",
rebalance_on="months",
training_period=60,
rolling_window=48)
```
https://cran.r-project.org/web/packages/PortfolioAnalytics/PortfolioAnalytics.pdfShown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.