Description Usage Arguments Details Value Author(s) Examples
Decomposes data matrix into factors and residual idiosyncratic component.
1 2 3 4 |
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 when build statistical
factor model, used when |
tol |
double object indicating relative tolerance to determine convergence when estimate
statistical factor model, 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 |
rtn_Sigma |
logical variable indicating whether to calculate and return the covariance matrix |
Decomposes data matrix into factors and residual idiosyncratic component. The
user can choose different types of factor models, namely, macroeconomic, BARRA,
or statistical. For macroeconomic factor model, set type = "Macro"
and pass
argument econ_fact
; for BARRA Industry factor model, set type = "Barra"
and pass argument stock_sector_info
(or make column names of X
be
in the in-built database data(stock_sector_database)
); for statistical
factors model, set type = "Stat-PCA"
and pass argument K
, max_iter
,
tol
and Psi_struct
, and possibly stock_sector_info
if a block
diagonal structure for Psi is required. This function can also estimate covariance
matrix when set rtn_Sigma = TRUE
. User can choose different type of residual
covariance matrix, namely, scaled identity, diagonal, block diagonal or full.
A list with following components:
|
vector of length N, the constant part |
|
matrix of dimension N x K, the loading matrix |
|
xts object of dimension T x K, the factor data matrix |
|
xts object of dimension T x N, the residual data matrix |
|
matrix of dimension N x N, the covariance matrix,
only returned when |
ZHOU Rui & Daniel P. Palomar
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 26 | # generate synthetic data
set.seed(234)
N <- 3 # number of stocks
T <- 5 # number of samples
mu <- rep(0, N)
Sigma <- diag(N)/1000
# generate asset returns TxN data matrix
X <- xts(mvrnorm(T, mu, Sigma), order.by = as.Date('2017-04-15') + 1:T)
colnames(X) <- c("A", "B", "C")
# generate K=2 macroeconomic factors
econ_fact <- xts(mvrnorm(T, c(0, 0), diag(2)/1000), order.by = index(X))
colnames(econ_fact) <- c("factor1", "factor2")
# build a macroeconomic factor model
macro_econ_model <- factorModel(X, type = "Macro", econ_fact = econ_fact)
# build a BARRA industry factor model
# (assuming assets A and C belong to sector 1 and asset B to sector 2)
stock_sector_info <- c(1, 2, 1)
barra_model <- factorModel(X, type = "Barra", stock_sector_info = stock_sector_info)
# build a statistical factor model
# set factor dimension as K=2
stat_model <- factorModel(X, K = 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.