Code Monkey home page Code Monkey logo

rolloptim's Introduction

rolloptim

Overview

rolloptim is a package that provides analytical computation of rolling optimization for time-series data.

Installation

Install the development version from GitHub:

# install.packages("devtools")
devtools::install_github("jasonjfoster/rolloptim") # roll (>= 1.1.7)

Usage

Load the package and supply a dataset:

library(rolloptim)

n_vars <- 3
n_obs <- 15
x <- matrix(rnorm(n_obs * n_vars), nrow = n_obs, ncol = n_vars)
y <- rnorm(n_obs)

mu <- roll::roll_mean(x, 5)
xx <- roll::roll_crossprod(x, x, 5)
xy <- roll::roll_crossprod(x, y, 5)
sigma <- roll::roll_cov(x, width = 5)

Then, to compute rolling optimization, use the functions:

# rolling optimization to minimize variance
roll_min_var(sigma)

# rolling optimization to maximize mean
roll_max_mean(mu)

# rolling optimization to minimize residual sum of squares
roll_min_rss(xx, xy)

# rolling optimization to maximize utility
roll_max_utility(mu, sigma, lambda = 1)

Note that handling of constraints is implemented by default (see the total, lower, and upper arguments).

References

Markowitz, H.M. (1952). "Portfolio Selection." The Journal of Finance, 7(1), 77โ€“91.

Tam, A. (2021). "Lagrangians and Portfolio Optimization." https://www.adrian.idv.hk/2021-06-22-kkt/.

rolloptim's People

Contributors

jasonjfoster avatar

Stargazers

timelyportfolio avatar  avatar  avatar  avatar

Watchers

timelyportfolio avatar  avatar  avatar Kostas Georgiou avatar

rolloptim's Issues

r-universe for all the `roll*` suite

Hi, so happy to have found your great work on roll* suite of packages through the R in Finance speaker site. Look forward to hearing your presentation and hopefully meeting you there. I was wondering if you might be interested in setting up your own roll* r-universe which only contains roll currently https://jasonjfoster.r-universe.dev/builds. I would really enjoy playing with all of the roll* packages, and given my setup (corporate security limitations or through webr), this would be much easier if available at r-universe.

Thanks so much for sharing your packages.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.