knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of DOSPorfolio is to provide a simple interface for computing portfolio weights according to the dynamic weighting scheme from [@BODNAR21dynshrink].
The development version can be installed from GitHub with:
# install.packages("devtools") devtools::install_github("Statistics-In-Portfolio-Theory/DOSportfolio")
This is a very simple example which shows you how use the package:
library(DOSPortfolio) n <- 25*2 p <- 15 # Simulate data data <- sqrt(5/3) * matrix(rt(n*p, df=5), ncol=p, nrow=n) # specify the allocation points. The DOSPortfolio class will validate what is # "ok" allocation periods. reallocation_points <- c(25, 42) (portfolios <- DOSPortfolio(data, reallocation_points))
The variable portfolios
is a "DOSPortfolio" class whose documentation can be
viewed by ?DOSPortfolio
. The constructor DOSPortfolio()
looks for violations
against the assumptions made in the reference. Here is an example when things
does not work
reallocation_points <- c(37, 42) # observe that there is little data between the first and second allcoation # point. Its actually to little since p > n_2, e.g. 15 > 42 - 37. # This will cause an error DOSPortfolio(data, reallocation_points)
However, by using the the argument shrinkage_type="overlapping"
we can
make it work!
DOSPortfolio(data, reallocation_points, shrinkage_type = "overlapping")
If you want to learn to more why this is then you can have a look at the "introduction" vignette or read the paper!
tsibble
package?Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.