repRisk {facmodCS}R Documentation

Decompose portfolio risk into individual factor contributions and provide tabular report

Description

Compute the factor contributions to standard deviation (SD), Value-at-Risk (VaR), Expected Tail Loss or Expected Shortfall (ES) of the return of individual asset within a portfolio return of a portfolio based on Euler's theorem, given the fitted factor model.

Usage

repRisk(object, ...)

## S3 method for class 'ffm'
repRisk(
  object,
  weights = NULL,
  risk = c("Sd", "VaR", "ES"),
  decomp = c("FMCR", "FCR", "FPCR"),
  digits = NULL,
  invert = FALSE,
  nrowPrint = 20,
  p = 0.05,
  type = c("np", "normal"),
  sliceby = c("factor", "asset", "riskType"),
  isPrint = TRUE,
  isPlot = FALSE,
  layout = NULL,
  stripText.cex = 1,
  axis.cex = 1,
  portfolio.only = FALSE,
  ...
)

Arguments

object

fit object of class tsfm, or ffm.

...

other optional arguments passed to quantile and optional arguments passed to cov

weights

a vector of weights of the assets in the portfolio, names of the vector should match with asset names. Default is NULL, in which case an equal weights will be used.

risk

one of 'Sd' (standard deviation), 'VaR' (Value-at-Risk) or 'ES' (Expected Tail Loss or Expected Shortfall for calculating risk decompositon. Default is 'Sd'

decomp

one of 'FMCR' (factor marginal contribution to risk), 'FCR' 'factor contribution to risk' or 'FPCR' (factor percent contribution to risk).

digits

digits of number in the resulting table. Default is NULL, in which case digtis = 3 will be used for decomp = ( 'FMCR', 'FCR'), digits = 1 will be used for decomp = 'FPCR'. Used only when isPrint = 'TRUE'

invert

a logical variable to change VaR/ES to positive number, default is False and will return positive values.

nrowPrint

a numerical value deciding number of assets/portfolio in result vector/table to print or plot

p

tail probability for calculation. Default is 0.05.

type

one of "np" (non-parametric) or "normal" for calculating VaR & Es. Default is "np".

sliceby

one of 'factor' (slice/condition by factor) or 'asset' (slice/condition by asset) or 'riskType' Used only when isPlot = 'TRUE'

isPrint

logical variable to print numeric output or not.

isPlot

logical variable to generate plot or not.

layout

layout is a numeric vector of length 2 or 3 giving the number of columns, rows, and pages (optional) in a multipanel display.

stripText.cex

a number indicating the amount by which strip text in the plot(s) should be scaled relative to the default. 1=default, 1.5 is 50% larger, 0.5 is 50% smaller, etc.

axis.cex

a number indicating the amount by which axis in the plot(s) should be scaled relative to the default. 1=default, 1.5 is 50% larger, 0.5 is 50% smaller, etc.

portfolio.only

logical variable to choose if to calculate portfolio only decomposition, in which case multiple risk measures are allowed.

Value

A table containing

decomp = 'FMCR'

(N + 1) * (K + 1) matrix of marginal contributions to risk of portfolio return as well assets return, with first row of values for the portfolio and the remaining rows for the assets in the portfolio, with (K + 1) columns containing values for the K risk factors and the residual respectively

decomp = 'FCR'

(N + 1) * (K + 2) matrix of component contributions to risk of portfolio return as well assets return, with first row of values for the portfolio and the remaining rows for the assets in the portfolio, with first column containing portfolio and asset risk values and remaining (K + 1) columns containing values for the K risk factors and the residual respectively

decomp = 'FPCR'

(N + 1) * (K + 1) matrix of percentage component contributions to risk of portfolio return as well assets return, with first row of values for the portfolio and the remaining rows for the assets in the portfolio, with (K + 1) columns containing values for the K risk factors and the residual respectively

Where, K is the number of factors, N is the number of assets.

Author(s)

Douglas Martin, Lingjie Yi

See Also

fitFfm for the different factor model fitting functions.

Examples



# Fundamental Factor Model
library(PCRA)

dateRange <- c("2006-01-31","2010-12-31")
stockItems <-  c("Date", "TickerLast",  "Return","Sector")
factorItems <- c("BP","Beta60M","PM12M1M")
facDatIT <- selectCRSPandSPGMI("monthly",
                               dateRange = dateRange, 
                               stockItems = stockItems, 
                               factorItems = factorItems, 
                               outputType = "data.table")
asset.var="TickerLast" 
ret.var="Return" 
date.var = "Date"
exposure.vars= factorItems
asset.var="TickerLast" 
ret.var="Return" 
date.var = "Date"
spec1 <- specFfm(data = facDatIT,asset.var = asset.var, ret.var = ret.var, 
                date.var = date.var, exposure.vars = exposure.vars,weight.var = NULL,
                 addIntercept = TRUE, rob.stats = FALSE)
# fit a fundamental factor model
mdlFit <- fitFfmDT(spec1)
mdlRes <- extractRegressionStats(spec1,mdlFit)
fit.cross <- convert(SpecObj = spec1,FitObj = mdlFit, RegStatsObj = mdlRes)
repRisk(fit.cross, risk = "Sd", decomp = 'FCR', nrowPrint = 10,  digits = 4) 
# get the factor contributions of risk 
repRisk(fit.cross, risk = "Sd", decomp = 'FPCR', 
        nrowPrint = 10)       
           
# portfolio only decomposition
repRisk(fit.cross, risk = c("VaR", "ES"), decomp = 'FPCR', 
        portfolio.only = TRUE)    
           
# plot
repRisk(fit.cross, risk = "Sd", decomp = 'FPCR', 
        isPrint = FALSE, nrowPrint = 15, isPlot = TRUE, layout = c(4,2))  


[Package facmodCS version 1.0 Index]