portSdDecomp | R Documentation |
Compute the factor contributions to standard deviation (Sd) of portfolio returns based on Euler's theorem, given the fitted factor model.
portSdDecomp(object, ...)
## S3 method for class 'tsfm'
portSdDecomp(
object,
weights = NULL,
factor.cov,
use = "pairwise.complete.obs",
...
)
## S3 method for class 'ffm'
portSdDecomp(object, weights = NULL, factor.cov, ...)
object |
fit object of class |
... |
optional arguments passed to |
weights |
a vector of weights of the assets in the portfolio. Default is NULL, in which case an equal weights will be used. |
factor.cov |
optional user specified factor covariance matrix with named columns; defaults to the sample covariance matrix. |
use |
an optional character string giving a method for computing covariances in the presence of missing values. This must be (an abbreviation of) one of the strings "everything", "all.obs", "complete.obs", "na.or.complete", or "pairwise.complete.obs". Default is "pairwise.complete.obs". |
The factor model for a portfolio's return at time t
has the
form
R(t) = beta'f(t) + e(t) = beta.star'f.star(t)
where, beta.star=(beta,sig.e)
and f.star(t)=[f(t)',z(t)]'
.
By Euler's theorem, the standard deviation of the portfolio's return
is given as:
portSd = sum(cSd_k) = sum(beta.star_k*mSd_k)
where, summation is across the K
factors and the residual,
cSd
and mSd
are the component and marginal
contributions to Sd
respectively. Computing portSd
and
mSd
is very straight forward. The formulas are given below and
details are in the references. The covariance term is approximated by the
sample covariance.
portSd = sqrt(beta.star''cov(F.star)beta.star)
mSd = cov(F.star)beta.star / portSd
A list containing
portSd |
factor model Sd of portfolio return. |
mSd |
length-(K + 1) vector of marginal contributions to Sd. |
cSd |
length-(K + 1) vector of component contributions to Sd. |
pcSd |
length-(K + 1) vector of percentage component contributions to Sd. |
Where, K is the number of factors.
Douglas Martin, Lingjie Yi
fitTsfm
, fitFfm
for the different factor model fitting functions.
portVaRDecomp
for portfolio factor model VaR decomposition.
portEsDecomp
for portfolio factor model ES decomposition.
# Time Series Factor Model
# load data
data(managers, package = 'PerformanceAnalytics')
colnames(managers)
# Make syntactically valid column names
colnames(managers) <- make.names( colnames(managers))
colnames(managers)
fit.macro <- FactorAnalytics::fitTsfm(asset.names=colnames(managers[,(1:6)]),
factor.names=colnames(managers[,(7:9)]),
rf.name=colnames(managers[,10]),
data=managers)
decomp <- portSdDecomp(fit.macro)
# get the factor contributions of risk
decomp$cSd
# random weights
wts = runif(6)
wts = wts/sum(wts)
names(wts) <- colnames(managers)[1:6]
portSdDecomp(fit.macro, wts)
# Fundamental Factor Model
data("stocks145scores6")
dat = stocks145scores6
dat$DATE = zoo::as.yearmon(dat$DATE)
dat = dat[dat$DATE >=zoo::as.yearmon("2008-01-01") & dat$DATE <= zoo::as.yearmon("2012-12-31"),]
# Load long-only GMV weights for the return data
data("wtsStocks145GmvLo")
wtsStocks145GmvLo = round(wtsStocks145GmvLo,5)
# fit a fundamental factor model
fit.cross <- fitFfm(data = dat,
exposure.vars = c("SECTOR","ROE","BP","PM12M1M","SIZE","ANNVOL1M",
"EP"),date.var = "DATE", ret.var = "RETURN", asset.var = "TICKER",
fit.method="WLS", z.score = "crossSection")
decomp = portSdDecomp(fit.cross)
# get the factor contributions of risk
decomp$cSd
portSdDecomp(fit.cross, wtsStocks145GmvLo)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.