Description Usage Arguments Details Value Author(s) References Examples
Estimate covariance matrix through factor model.
1 2 3 | covFactorModel(X, type = "Stat-PCA", econ_fact = NA, K = 1,
orthonormal = "factor", max_iter = 10, tol = 0.001, epsilon = 0,
Psi_struct = "diag", stock_sector_info = NA)
|
X |
xts object of dimension T x N, with T number of observations and N number of assets |
type |
string object indicating the type of factor model to be used:
|
econ_fact |
xts object of dimension T x K, required and used when |
K |
number of factors when build a statistical factor model, used when |
orthonormal |
string object indicating position of normalization in the statistical factor
model, used when
|
max_iter |
positive integer indicating maximum number of iterations,
used when |
tol |
double object indicating relative tolerance to determine convergence,
used when |
epsilon |
nonnegative scale indicating lower bound of residual covariance matrix's diagonal elements,
used when |
Psi_struct |
string indicating type of structure imposed on the covariance matrix of the residuals,
|
stock_sector_info |
positive integer vector of length N, used when |
see factorModel
matrix of dimension N x N, the covariance matrix
ZHOU Rui & Daniel P. Palomar
K. Khamaru and R. Mazumder, “Computation of the maximum likelihood estimator in low-rank factor analysis,” arXiv preprint arXiv:1801.05935, 2018.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # generate synthetic data
set.seed(234)
K <- 1 # number of factors
N <- 400 # number of stocks
mu <- rep(0, N)
beta <- mvrnorm(N, rep(1,K), diag(K)/10)
Sigma <- beta %*% t(beta) + diag(N)
# estimate error by loop
err_scm_vs_T <- c()
err_statPCA_diag_vs_T <- c()
index_T <- c()
for (T in N*seq(5)) {
X <- xts(mvrnorm(T, mu, Sigma), order.by = as.Date('1995-03-15') + 1:T)
# use statistical factor model by PCA
cov_statPCA_diag <- covFactorModel(X, K = K, max_iter = 10)
err_statPCA_diag_vs_T <- c(err_statPCA_diag_vs_T, norm(Sigma - cov_statPCA_diag, "F")^2)
# use sample covariance matrix
err_scm_vs_T <- c(err_scm_vs_T, norm(Sigma - cov(X), "F")^2)
index_T <- c(index_T, T)
}
res <- rbind(index_T/N, err_scm_vs_T, err_statPCA_diag_vs_T)
rownames(res) <- c("T/N", "SCM", "stat-PCA + diag")
print(res)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.