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

Description Usage Arguments Details Value Author(s) References Examples

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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 = FALSE, resid.EWMA = FALSE,
  lambda = 0.9, stdReturn = FALSE, fullPeriod = FALSE,
  windowLength = 60, 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. Default is FALSE.

lagExposures

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

resid.EWMA

logical; If TRUE, the residual variances are computed using EWMA and these would be used as weights for "WLS" or "W-Rob". Deafault is FALSE.

lambda

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

stdReturn

logical; If TRUE, the returns will be standardized using GARCH(1,1) volatilities. Default is FALSE

fullPeriod

logical; If TRUE, the fundamental law of active management will apply to all but the last time period. Default is FALSE

windowLength

integer; the number of months used as a window length in the FLAM analysis. Default is 60 (5 years).

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 lmRob. "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.

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.

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. Chindhanai Uthaisaad expanded the functionalities for the fundamental law of active management

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 lmRob 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

length-N vector of residual variances.

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.

condAlpha

length-windowLength the conditional mean of the portfolio returns in each moving window.

condOmega

length-windowLength list of the conditional covariance matrices of the portfolio returns in each moving window.

IR

the vector of in-sample IR, out-f-sample IR, and the standard error of the out-of-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.

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
42
43
44
45
46
47
48
49
50
51
52
53
54
# Load fundamental and return data
 data("factorDataSetDjia5Yrs")

# fit a fundamental factor model
exposure.vars <- c("P2B", "MKTCAP")
fit <- fitFfm(data=factorDataSetDjia5Yrs, asset.var="TICKER", ret.var="RETURN", 
              date.var="DATE", exposure.vars=exposure.vars)
names(fit)

# fit a Industry Factor Model with Intercept
exposure.vars <- c("SECTOR","P2B")
fit1 <- fitFfm(data=factorDataSetDjia5Yrs, asset.var="TICKER", ret.var="RETURN", 
               date.var="DATE", exposure.vars=exposure.vars, addIntercept=TRUE)
               
# Fit a SECTOR+COUNTRY+Style model with Intercept
# Create a COUNTRY column with just 3 countries

 factorDataSetDjia5Yrs$COUNTRY = rep(rep(c(rep("US", 1 ),rep("GERMANY", 1 )), 11), 60)
 exposure.vars= c("SECTOR", "COUNTRY","P2B", "MKTCAP")
 
 fit.MICM <- fitFfm(data=factorDataSetDjia5Yrs, asset.var="TICKER", ret.var="RETURN", 
                   date.var="DATE", exposure.vars=exposure.vars, addIntercept=TRUE)
                   
data("mktSP")
data("factorDataSetDjia")
factorDataSetDjia <- factorDataSetDjia[order(factorDataSetDjia[, "DATE"]), ]
# Extract asset names from data
asset.names <- unique(factorDataSetDjia[["TICKER"]])
N_stocks <- length(asset.names)
time.periods <- unique(factorDataSetDjia[["DATE"]])
N_TP <- length(time.periods)
bmkReturn <- mktSP[index(mktSP) %in% time.periods, ]

totReturns = matrix(factorDataSetDjia[["RETURN"]], nrow = N_stocks)[1:N_stocks, ]
rownames(totReturns) = asset.names

# Compute residual returns from CAPM----
residReturns <- totReturns
beta_i <- c()
for (i in 1:N_stocks) {
  beta_i[i] <- c(cov(totReturns[i, ] , bmkReturn) / var(bmkReturn))
  residReturns[i, ] <- totReturns[i, ] - beta_i[i] * bmkReturn
}

modData <- cbind(factorDataSetDjia, "RESIDRETURN" = as.vector(residReturns))
sizeFfm <- fitFfm(modData, asset.var = "TICKER", ret.var = "RESIDRETURN",
                  exposure.vars = c("SIZE"), addIntercept = TRUE, stdReturn = FALSE,
                  z.score = "crossSection", date.var = "DATE", lagExposures = TRUE, 
                  analysis = "ISM")
                  
p2bFfm <- fitFfm(modData, asset.var = "TICKER", ret.var = "RESIDRETURN",
                 exposure.vars = c("P2B"), addIntercept = TRUE, stdReturn = TRUE,
                 z.score = "timeSeries", date.var = "DATE", lagExposures = TRUE, 
                 analysis = "NEW")

chindhanai/factorAnalytics documentation built on May 20, 2019, 7:55 a.m.