Description Usage Arguments Details Value Author(s) References See Also Examples
Fits a statistical factor model using Principal Component
Analysis (PCA) for one or more asset returns or excess returns. When the
number of assets exceeds the number of time periods, Asymptotic Principal
Component Analysis (APCA) is performed. An object of class "sfm"
is
returned. This function is based on the S+FinMetric function mfactor
.
1 2 3 4 5 6 7 8 9 10 11 |
data |
vector, matrix, data.frame, xts, timeSeries or zoo object with asset returns. See details. |
k |
number of factors (or) a method for determining the optimal number of factors, one of "bn" or "ck". See details. Default is 1. |
max.k |
scalar; the maximum number of factors to be considered for
methods "bn" or "ck". Default is |
refine |
logical; whether to use the Connor-Korajczyk refinement for
APCA. Default is |
sig |
scalar; desired level of significance when "ck" method is specified. Default is 0.05. |
check |
logical; to check if any asset has identical observations.
Default is |
corr |
logical; whether to use the correlation instead of the covariance
matrix when finding the principal components. Default is |
... |
optional arguments passed to |
object |
a fit object of class |
If data
is not of class "xts"
, rownames must provide an
"xts"
compatible time index. Before model fitting, incomplete cases in
data
are removed using na.omit
. Specifying
check=TRUE
, issues a warning if any asset is found to have identical
observations.
Let N
be the number of columns or assets and T
be the number
of rows or observations. When N < T
, Principal Component Analysis
(PCA) is performed. Any number of factors less than min(N,T)
can be
chosen via argument k
. Default is 1. Refer to Zivot and Wang (2007)
for more details and references.
When N >= T
, Asymptotic Principal Component Analysis (APCA) is
performed. The user can directly specify k
similar to PCA above, or a
method to automatically determine the number of factors can be specified:
k="bn"
corresponds to Bai and Ng (2002) and k="ck"
corresponds
to Connor and Korajczyk (1993). Users can choose the maximum number of
factors, max.k
, to consider with these methods. The default for
max.k
is set to be 10 or $T-1$, whichever is smaller.
refine
specifies whether a refinement of the APCA procedure from
Connor and Korajczyk (1988), that may improve efficiency, is to be used.
When corr=TRUE
, the correlation matrix of returns are used for
finding the principal components instead of the covariance matrix. This is
typically decided by practioners on a case-by-case basis. The variable with
the highest variance dominates the PCA when the covariance matrix is used.
However, this may be justified if a volatile asset is more interesting for
some reason and volatility information shouldn't be discarded. On the other
hand, using the correlation matrix standardizes the variables and makes them
comparable, avoiding penalizing variables with less dispersion.
Finally, if the median of the 1st principal component is negative, all it's factor realizations are automatically inverted to enable more meaningful interpretation.
fitTsfm returns an object of class "sfm"
for which
print
, plot
, predict
and summary
methods exist.
The generic accessor functions coef
, fitted
and
residuals
extract various useful features of the fit object.
Additionally, fmCov
computes the covariance matrix for asset returns
based on the fitted factor model
An object of class "sfm"
is a list containing the following
components:
asset.fit |
fitted object of class |
k |
number of factors; as input or determined by "ck" or "bn" methods. |
factors |
T x K xts object of estimated factor realizations. |
loadings |
N x K matrix of factor loadings estimated by regressing the asset returns on estimated factors. |
alpha |
length-N vector of estimated alphas. |
r2 |
length-N vector of R-squared values. |
resid.sd |
length-N vector of residual standard deviations. |
residuals |
T x N xts object of residuals from the LS regression. |
Omega |
N x N return covariance matrix estimated by the factor model. |
eigen |
length-N (or length-T for APCA) vector of eigenvalues of the sample covariance matrix. |
mimic |
N x K matrix of factor mimicking portfolio weights. |
call |
the matched function call. |
data |
T x N xts data object containing the asset returns. |
asset.names |
length-N vector of column names from data. |
Where N is the number of assets, K is the number of factors, and T is the number of observations.
Eric Zivot, Sangeetha Srinivasan and Yi-An Chen
Bai, J., & Ng, S. (2002). Determining the number of factors in approximate factor models. Econometrica, 70(1), 191-221.
Connor, G., & Korajczyk, R. A. (1988). Risk and return in an equilibrium APT: Application of a new test methodology. Journal of Financial Economics, 21(2), 255-289.
Connor, G., & Korajczyk, R. A. (1993). A test for the number of factors in an approximate factor model. The Journal of Finance, 48(4), 1263-1291.
Zivot, E., & Wang, J. (2007). Modeling Financial Time Series with S-PLUS (Vol. 191). Springer.
The sfm
methods for generic functions:
plot.sfm
, predict.sfm
,
print.sfm
and summary.sfm
.
And, the following extractor functions: coef
,
fitted
, residuals
,
fmCov
, fmSdDecomp
, fmVaRDecomp
and fmEsDecomp
.
paFm
for Performance Attribution.
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 27 28 29 | # load return data
data(StockReturns)
# PCA is performed on r.M and APCA on r.W
class(r.M)
dim(r.M)
range(rownames(r.M))
class(r.W)
dim(r.W)
# PCA
args(fitSfm)
fit.pca <- fitSfm(r.M, k=2)
class(fit.pca)
names(fit.pca)
head(fit.pca$factors)
head(fit.pca$loadings)
fit.pca$r2
fit.pca$resid.sd
fit.pca$mimic
# APCA with number of factors, k=15
fit.apca <- fitSfm(r.W, k=15, refine=TRUE)
# APCA with the Bai & Ng method
fit.apca.bn <- fitSfm(r.W, k="bn")
# APCA with the Connor-Korajczyk method
fit.apca.ck <- fitSfm(r.W, k="ck")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.