repExposures: Portfolio Exposures Report

View source: R/repExposures.R

repExposuresR Documentation

Portfolio Exposures Report

Description

Calculate k factor time series based on fundamental factor model. This method takes fundamental factor model fit, 'ffm' object, and portfolio weight as inputs and generates numeric summary and plot visualization.

Usage

repExposures(
  ffmObj,
  weights = NULL,
  isPlot = TRUE,
  isPrint = TRUE,
  scaleType = "free",
  stripText.cex = 1,
  axis.cex = 1,
  stripLeft = TRUE,
  layout = NULL,
  color = "blue",
  notch = FALSE,
  digits = 1,
  titleText = TRUE,
  which = NULL,
  type = "b",
  ...
)

Arguments

ffmObj

an object of class ffm returned by fitFfm.

weights

a vector of weights of the assets in the portfolio. Default is NULL.

isPlot

logical variable to generate plot or not.

isPrint

logical variable to print numeric summary or not.

scaleType

scaleType controls if use a same scale of y-axis, choose from c('same', 'free')

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.

stripLeft

logical variable to choose the position of strip, 'TRUE' for drawing strips on the left of each panel, 'FALSE' for drawing strips on the top of each panel. Used only when isPlot = 'TRUE'

layout

layout is a numeric vector of length 2 or 3 giving the number of columns, rows, and pages (optional) in a multipanel display. Used only when isPlot = 'TRUE'

color

character specifying the plotting color for all the plots

notch

logical. if notch is TRUE, a notch is drawn in each side of the boxes. If the notches of two plots do not overlap this is strong evidence that the two medians differ (Chambers et al, 1983, p. 62).Default values is FALSE.

digits

digits of printout numeric summary. Used only when isPrint = 'TRUE'

titleText

logical varible to choose display plot title or not. Default is 'TRUE', and used only when isPlot = 'TRUE'.

which

a number to indicate the type of plot. If a subset of the plots is required, specify a subset of the numbers 1:3 for plots. If which=NULL (default), the following menu appears:

For plots of a group of assets:
1 = Time series plot of style factor exposures,
2 = Boxplot of style factor exposures,
3 = Barplot of means and vols of style factor exposures, and means of sector exposures (which have no vol).

type

character. type of lattice plot when which=1; 'l' denotes a line, 'p' denotes a point, and 'b' and 'o' both denote both together.deafault is 'b'.

...

other graphics parameters available in tsPlotMP(time series plot only) can be passed in through the ellipses

Value

A list containing mean and standard deviation of all the factors

Author(s)

Douglas Martin, Lingjie Yi, Avinash

Examples


#Load fundamental and return data 
# 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
exposure.vars = c("SECTOR","ROE","BP","PM12M1M","SIZE", "ANNVOL1M", "EP")
fit.cross <- fitFfm(data = dat, 
                    exposure.vars = exposure.vars,
                    date.var = "DATE", 
                    ret.var = "RETURN", 
                    asset.var = "TICKER", 
                    fit.method="WLS", 
                    z.score = "crossSection")

repExposures(fit.cross, wtsStocks145GmvLo, isPlot = FALSE, digits = 4)

repExposures(fit.cross, wtsStocks145GmvLo, isPrint = FALSE, isPlot = TRUE, 
             which = 2, add.grid = TRUE, scaleType = 'same')
             
repExposures(fit.cross, wtsStocks145GmvLo, isPlot = TRUE, which = 1,
             add.grid = FALSE, zeroLine = TRUE, color = 'Blue')
             
repExposures(fit.cross, wtsStocks145GmvLo, isPrint = FALSE, isPlot = TRUE, 
             which = 3, add.grid = FALSE, zeroLine = FALSE, color = 'Blue')

braverock/factorAnalytics documentation built on Dec. 16, 2024, 1:05 p.m.