Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

randomReturns

Create a Random Returns


Description

Create a matrix of random returns.

Usage

randomReturns(na, ns, sd, mean = 0, rho = 0)

Arguments

na

number of assets

ns

number of return scenarios

sd

the standard deviation: either a single number or a vector of length na

mean

the mean return: either a single number or a vector of length na

rho

correlation: either a scalar (i.e. a constant pairwise correlation) or a correlation matrix

Details

The function corresponds to the function random_returns, described in the second edition of NMOF (the book).

Value

a numeric matrix of size na times ns

Note

The function corresponds to the function random_returns, described in the second edition of NMOF (the book).

Author(s)

Enrico Schumann

References

Gilli, M., Maringer, D. and Schumann, E. (2019) Numerical Methods and Optimization in Finance, 2nd edition. Elsevier. https://www.elsevier.com/books/numerical-methods-and-optimization-in-finance/gilli/978-0-12-815065-8

Schumann, E. (2021) Financial Optimisation with R (NMOF Manual). http://enricoschumann.net/NMOF.htm#NMOFmanual

See Also

Examples

## a small experiment: when computing minimum-variance portfolios
## for correlated assets, how many large positions are in the portfolio?

na <- 100  ## number of assets
inc <-  5  ## minimum of assets to include

n <- numeric(10)
for (i in seq_along(n)) {
    R <- randomReturns(na = na,
                       ns = 500,
                       sd = seq(.2/.16, .5/.16, length.out = 100),
                       rho = 0.5)
    n[i] <- sum(minvar(cov(R), wmax = 1/inc)> 0.01)
}
summary(n)

NMOF

Numerical Methods and Optimization in Finance

v2.4-1
GPL-3
Authors
Enrico Schumann [aut, cre] (<https://orcid.org/0000-0001-7601-6576>)
Initial release
2021-04-09

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.