fit.risk.summary.report: fit.risk.summary.report

Description Usage Arguments Value Author(s) Examples

Description

Function to create risk model report from fundamental or statistical risk model output

Usage

1
2
fit.risk.summary.report(riskmod, bm.wgt.var, port.wgt.var,
  filename = NULL)

Arguments

riskmod

object returned by fit.fundamental() or fit.statistical()

bm.wgt.var

data.table containing ID in the first column and benchmark weights in the second column

port.wgt.var

data.table containing ID in the first column and portfolio weights in the second column

filename

if not NULL, results will be saved to a CSV file with the given filename

Value

An object with S3 class "fir.factor.models" containing:

list of portfolioTbl and securityTbl. The portfolio table contains the following data items for the portfolio:

*Portfolio.Holdings* - number of portfolio holdings

*Benchmark.Holdings* - number of benchmark holdings

*Total.Risk* - predicted standard deviation of the portfolio, aka absolute risk

*Benchmark.Risk* - predicted standard deviation of the benchmark

*Active.Risk* - predicted tracing error of the portfolio to the benchmark

*R.Squared* - the fraction of portfolio varinace explained by the benchmark

*Predicted.Beta* - forecasted beta based on the risk model

*Specific.Risk.Pct* - percent of *Total.Risk* not explaned by the risk model factors, aka idiosyncratic risk

*Factor.Risk.Pct* - percent of *Total.Risk* explaned by the risk model factors

*Group.Risk.Pct* - percent of *Total.Risk* explaned by the grouping (Sector/Industry) factor, if applicable The factor table contains the following data items for each factor:

*Contribution.to.Risk* - each factor's contribution to risk in the portfolio

*Factor.Std.Dev* - each factor's volatility in the portfolio

*Active.Exposure* - each factor's active exposure in the portfolio The security table contains the following data items for each security:

*portfolio.wgt* - each stock's weight in the portfolio

*benchmark.wgt* - each stock's weight in the benchmark

*active.wgt* - each stock's active weight (portfolio minus benchmark)

*ivol* - each stock's idiosyncratic volatility, aka stock specific risk

*predicted.beta* - each stock's predicted beta

*risk.contribution* - each stock's contribution to *Total.Risk*

*factor.exposures* - each stock's exposure to each factor in the risk model

Author(s)

Roger J. Bos, roger.bos@gmail.com

Examples

 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
30
31
32
33
34
35
36
37
38
39
40
41
### Statistical

retMat <- fit.data.cast(stock, item='RETURN', id.var = 'TICKER', date.var = 'DATE', reverse = TRUE)
fit <- fit.statistical(retMat)

stock <- as.data.table(stock)
stock[TICKER %in% c('SUNW','ORCL','MSFT'), portfolioWeight := 1/3, by=DATE]
stock[is.na(portfolioWeight), portfolioWeight := 0]
stock[, benchmarkWeight := 1/.N, by=DATE]
cols <- c("TICKER","portfolioWeight")
portfolioWeight <- stock[DATE == max(DATE), ..cols]
cols <- c("TICKER","benchmarkWeight")
benchmarkWeight <- stock[DATE == max(DATE), ..cols]

risk <- fit.risk.summary.report(riskmod = fit, bm.wgt.var = benchmarkWeight, port.wgt.var = portfolioWeight, filename = NULL)
risk$portfolioTbl
risk$securityTbl[Portfolio.Wgt > 0, ]


### Fundamental

stock <- as.data.table(stock)
stock[TICKER %in% c('SUNW','ORCL','MSFT'), portfolioWeight := 1/3, by=DATE]
stock[is.na(portfolioWeight), portfolioWeight := 0]
stock[, benchmarkWeight := 1/.N, by=DATE]
fit <- fit.fundamental(fitdata = stock, date.var = 'DATE', id.var = 'TICKER', return.var = 'RETURN',
                       weight.var = 'LOG.MARKETCAP', exposure.vars = c('NET.SALES','BOOK2MARKET','GICS.SECTOR'),
                       rob.stats = TRUE, z.score = FALSE, stdReturn = TRUE, calc.inv = TRUE, cov.wgt = FALSE, parkinson = FALSE)

stock <- as.data.table(stock)
stock[TICKER %in% c('SUNW','ORCL','MSFT'), portfolioWeight := 1/3, by=DATE]
stock[is.na(portfolioWeight), portfolioWeight := 0]
stock[, benchmarkWeight := 1/.N, by=DATE]
cols <- c("TICKER","portfolioWeight")
portfolioWeight <- stock[DATE == max(DATE), ..cols]
cols <- c("TICKER","benchmarkWeight")
benchmarkWeight <- stock[DATE == max(DATE), ..cols]

risk <- fit.risk.summary.report(riskmod = fit, bm.wgt.var = benchmarkWeight, port.wgt.var = portfolioWeight, filename = NULL)
risk$portfolioTbl
risk$securityTbl[Portfolio.Wgt > 0, ]

rogerjbos/fit.factor.models documentation built on July 23, 2020, 3:44 p.m.