colSubset {NMOF} | R Documentation |
Full-rank Column Subset
Description
Select a full-rank subset of columns of a matrix.
Usage
colSubset(x)
Arguments
x |
a numeric matrix |
Details
Uses qr
.
Value
A list:
columns |
indices of columns |
multiplier |
a matrix |
Author(s)
Enrico Schumann
References
Gilli, M., Maringer, D. and Schumann, E. (2019) Numerical Methods and Optimization in Finance. 2nd edition. Elsevier. doi:10.1016/C2017-0-01621-X
Schumann, E. (2023) Financial Optimisation with R (NMOF Manual). http://enricoschumann.net/NMOF.htm#NMOFmanual
See Also
Examples
nc <- 3 ## columns
nr <- 10 ## rows
M <- array(rnorm(nr * nc), dim = c(nr, nc))
C <- array(0.5, dim = c(nc, nc))
diag(C) <- 1
M <- M %*% chol(C)
M <- M[ ,c(1,1,1,2,3)]
M
(tmp <- colSubset(M))
C <- cor(M[ ,tmp$columns])
nc <- ncol(C)
nr <- 100
X <- array(rnorm(nr*nc), dim = c(nr, nc))
X <- X %*% chol(C)
X <- X %*% tmp$multiplier
head(X)
cor(X)
[Package NMOF version 2.8-0 Index]