Learn R Programming

NMOF (version 2.2-2)

resampleC: Resample with Specified Rank Correlation

Description

Resample with replacement from a number of vectors; the sample will have a specified rank correlation.

Usage

resampleC(..., size, cormat)

Arguments

numeric vectors; they need not have the same length.

size

an integer: the number of samples to draw

cormat

the rank correlation matrix

Value

a numeric matrix with size rows. The columns contain the samples; hence, there will be as many columns as vectors passed through .

Details

See Gilli, Maringer and Schumann (2011), Section 7.1.2. The function samples with replacement from the vectors passed through . The resulting samples will have an (approximate) rank correlation as specified in cormat.

The function uses the eigenvalue decomposition to generate the correlation; it will not break down in case of a semidefinite matrix. If an eigenvalue of cormat is smaller than zero, a warning is issued (but the function proceeds).

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. (2019) Financial Optimisation with R (NMOF Manual). http://enricoschumann.net/NMOF.htm#NMOFmanual

See Also

repairMatrix

Examples

Run this code
# NOT RUN {
## a sample
v1 <- rnorm(20)
v2 <- runif(50)
v3 <- rbinom(100, size = 50, prob = 0.4)

## a correlation matrix
cormat <- array(0.5, dim = c(3, 3))
diag(cormat) <- 1

cor(resampleC(a = v1, b = v2, v3, size = 100, cormat = cormat),
    method = "spearman")
# }

Run the code above in your browser using DataLab