colSubset | R Documentation |
Select a full-rank subset of columns of a matrix.
colSubset(x)
x |
a numeric matrix |
Uses qr
.
A list:
columns |
indices of columns |
multiplier |
a matrix |
Enrico Schumann
Gilli, M., Maringer, D. and Schumann, E. (2019) Numerical Methods and Optimization in Finance. 2nd edition. Elsevier. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/C2017-0-01621-X")}
Schumann, E. (2023) Financial Optimisation with R (NMOF Manual). https://enricoschumann.net/NMOF.htm#NMOFmanual
repairMatrix
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.