fitFfm: Fit a fundamental factor model using cross-sectional...

View source: R/fitFfm.R

fitFfmR Documentation

Fit a fundamental factor model using cross-sectional regression

Description

Fit a fundamental (cross-sectional) factor model using ordinary least squares or robust regression. Fundamental factor models use observable asset specific characteristics (or) fundamentals, like industry classification, market capitalization, style classification (value, growth) etc. to calculate the common risk factors. An object of class "ffm" is returned.

Usage

fitFfm(
  data,
  asset.var,
  ret.var,
  date.var,
  exposure.vars,
  weight.var = NULL,
  fit.method = c("LS", "WLS", "Rob", "W-Rob"),
  rob.stats = FALSE,
  full.resid.cov = FALSE,
  z.score = c("none", "crossSection", "timeSeries"),
  addIntercept = FALSE,
  lagExposures = TRUE,
  resid.scaleType = "stdDev",
  lambda = 0.9,
  GARCH.params = list(omega = 0.09, alpha = 0.1, beta = 0.81),
  GARCH.MLE = FALSE,
  stdReturn = FALSE,
  analysis = c("none", "ISM", "NEW"),
  targetedVol = 0.06,
  ...
)

## S3 method for class 'ffm'
coef(object, ...)

## S3 method for class 'ffm'
fitted(object, ...)

## S3 method for class 'ffm'
residuals(object, ...)

Arguments

data

data.frame of the balanced panel data containing the variables asset.var, ret.var, exposure.vars, date.var and optionally, weight.var.

asset.var

character; name of the variable for asset names.

ret.var

character; name of the variable for asset returns.

date.var

character; name of the variable containing the dates coercible to class Date.

exposure.vars

vector; names of the variables containing the fundamental factor exposures.

weight.var

character; name of the variable containing the weights used when standarizing style factor exposures. Default is NULL. See Details.

fit.method

method for estimating factor returns; one of "LS", "WLS" "Rob" or "W-Rob". See details. Default is "LS".

rob.stats

logical; If TRUE, robust estimates of covariance, correlation, location and univariate scale are computed as appropriate (see Details). Default is FALSE.

full.resid.cov

logical; If TRUE, a full residual covariance matrix is estimated. Otherwise, a diagonal residual covariance matrix is estimated. Default is FALSE.

z.score

method for exposure standardization; one of "none", "crossSection", or "timeSeries". Default is "none".

addIntercept

logical; If TRUE, intercept is added in the exposure matrix. Note, if 2 or more variables are categorical, this must be false. Default is FALSE.

lagExposures

logical; If TRUE, the style exposures in the exposure matrix are lagged by one time period. Default is TRUE,

resid.scaleType

character; Only valid when fit.method is set to WLS or W-Rob. The weights used in the weighted regression are estimated using sample variance, classic EWMA, robust EWMA or GARCH model. Valid values are stdDev, EWMA, robEWMA, or GARCH.Default is stdDev where the inverse of residual sample variances are used as the weights. If using GARCH option, make sure to install and load rugarch package.

lambda

lambda value to be used for the EWMA estimation of residual variances. Default is 0.9

GARCH.params

list containing GARCH parameters omega, alpha, and beta. Default values are (0.09, 0.1, 0.81) respectively. Valid only when GARCH.MLE is set to FALSE. Estimation outsourced to the rugarch package, please load it first.

GARCH.MLE

boolean input (TRUE|FALSE), default value = FALSE. This argument allows one to choose to compute GARCH parameters by maximum likelihood estimation. Estimation outsourced to the rugarch package, please load it.

stdReturn

logical; If TRUE, the returns will be standardized using GARCH(1,1) volatilities. Default is FALSE. Make sure to load rugarch package.

analysis

method used in the analysis of fundamental law of active management; one of "none", "ISM", or "NEW". Default is "none".

targetedVol

numeric; the targeted portfolio volatility in the analysis. Default is 0.06.

...

potentially further arguments passed.

object

a fit object of class ffm which is returned by fitFfm

Details

Estimation method "LS" corresponds to ordinary least squares using lm and "Rob" is robust regression using lmrobdetMM. "WLS" is weighted least squares using estimates of the residual variances from LS regression as weights (feasible GLS). Similarly, "W-Rob" is weighted robust regression.

The weights to be used in "WLS" or "W-Rob" can be set using resid.scaleType argument which computes the residual variances in one of the following ways - sample variace, EWMA, Robust EWMA and GARCH(1,1). The inverse of these residual variances are used as the weights. For EWMA model, lambda = 0.9 is used as default and for GARCH(1,1) omega = 0.09, alpha = 0.1, and beta = 0.81 are used as default as mentioned in Martin & Ding (2017). These default parameters can be changed using the arguments lambda, GARCH.params for EWMA and GARCH respectively. To compute GARCH parameters via MLE, set GARCH.MLE to TRUE. Make sure you have the rugarch package installed and loaded, as is merely listed as SUGGESTS.

Standardizing style factor exposures: The exposures can be standardized into z-scores using regular or robust (see rob.stats) measures of location and scale. Further, weight.var, a variable such as market-cap, can be used to compute the weighted mean exposure, and an equal-weighted standard deviation of the exposures about the weighted mean. This may help avoid an ill-conditioned covariance matrix. Default option equally weights exposures of different assets each period.

If rob.stats=TRUE, covRob is used to compute a robust estimate of the factor covariance/correlation matrix, and, scaleTau2 is used to compute robust tau-estimates of univariate scale for residuals during "WLS" or "W-Rob" regressions. When standardizing style exposures, the median and mad are used for location and scale respectively. When resid.scaleType is EWMA or GARCH, the residual covariance is equal to the diagonal matrix of the estimated residual variances in last time period.

The original function was designed by Doug Martin and initially implemented in S-PLUS by a number of University of Washington Ph.D. students: Christopher Green, Eric Aldrich, and Yindeng Jiang. Guy Yollin ported the function to R and Yi-An Chen modified that code. Sangeetha Srinivasan re-factored, tested, corrected and expanded the functionalities and S3 methods.

Value

fitFfm returns an object of class "ffm" 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 "ffm" is a list containing the following components:

factor.fit

list of fitted objects that estimate factor returns in each time period. Each fitted object is of class lm if fit.method="LS" or "WLS", or, class lmrobdetMM if fit.method="Rob" or "W-Rob".

beta

N x K matrix of factor exposures for the last time period.

factor.returns

xts object of K-factor returns (including intercept).

residuals

xts object of residuals for N-assets.

r2

length-T vector of R-squared values.

factor.cov

K x K covariance matrix of the factor returns.

g.cov

covariance matrix of the g coefficients for a Sector plus market and Sector plus Country plus global market models .

resid.cov

N x N covariance matrix of residuals.

return.cov

N x N return covariance estimated by the factor model, using the factor exposures from the last time period.

restriction.mat

The restriction matrix used in the computation of f=Rg.

resid.var

N x T matrix of estimated residual variances. It will be a length-N vector of sample residual variances when resid.scaleType is set to stdDev

call

the matched function call.

data

data frame object as input.

date.var

date.var as input

ret.var

ret.var as input

asset.var

asset.var as input.

exposure.vars

exposure.vars as input.

weight.var

weight.var as input.

fit.method

fit.method as input.

asset.names

length-N vector of asset names.

factor.names

length-K vector of factor.names.

time.periods

length-T vector of dates.

Where N is the number of assets, K is the number of factors (including the intercept or dummy variables) and T is the number of unique time periods.

activeWeights

active weights obtaining from the fundamental law of active management

activeReturns

active returns corresponding to the active weights

IR

the vector of Granold-K, asymptotic IR, and finite-sample IR.

Where N is the number of assets, K is the number of factors (including the intercept or dummy variables) and T is the number of unique time periods.

Author(s)

Sangeetha Srinivasan, Guy Yollin, Yi-An Chen, Avinash Acharya and Chindhanai Uthaisaad

References

Menchero, J. (2010). The Characteristics of Factor Portfolios. Journal of Performance Measurement, 15(1), 52-62.

Grinold, R. C., & Kahn, R. N. (2000). Active portfolio management (Second Ed.). New York: McGraw-Hill.

Ding, Z. and Martin, R. D. (2016). "The Fundamental Law of Active Management Redux", SSRN 2730434.

And, the following extractor functions: coef, fitted, residuals, fmCov, fmSdDecomp, fmVaRDecomp and fmEsDecomp.

paFm for Performance Attribution.

Examples


## Not run: 
# load data
data(stocksCRSP)
data(factorsSPGMI)

stocks_factors <- selectCRSPandSPGMI(stocks = stocksCRSP, factors = factorsSPGMI,
                                    dateSet = c("2006-01-31", "2010-12-31"),
                                    stockItems = c("Date", "TickerLast",
                                                   "CapGroup", "Sector",
                                                   "Return", "Ret13WkBill",
                                                   "mktIndexCRSP"),
                                    factorItems = c("BP", "LogMktCap", "SEV"),
                                    capChoice = "SmallCap",
                                    Nstocks = 20)

# fit a fundamental factor model with style variables BP and LogMktCap

fundamental_model <- fitFfm(data = stocks_factors,
                           asset.var = "TickerLast",
                           ret.var = "Return",
                           date.var = "Date",
                           exposure.vars = c("BP", "LogMktCap")
                           )

  summary(fundamental_model)

# Fit a Fundamental Sector Factor Model with Intercept

 sector_model <- fitFfm(data = stocks_factors,
                        asset.var = "TickerLast",
                        ret.var = "Return",
                        date.var = "Date",
                        exposure.vars = c("Sector", "BP"),
                        addIntercept = TRUE)

 summary(sector_model)

## End(Not run)



braverock/factorAnalytics documentation built on March 2, 2024, 11:17 p.m.