ffmTstats: t-stats and Plots for a fitted Fundamental Factor Model

Description Usage Arguments Value Author(s) Examples

View source: R/ffmTstats.R

Description

Calculate and plot the time series of the t-statistic values and the number of risk indices with significant t-stats for a fundamentally fit object.

Usage

1
2
3
ffmTstats(ffmObj, isPlot = TRUE, isPrint = FALSE, myColor = c("black",
  "cyan"), lwd = 2, digits = 2, z.alpha = 1.96, layout = c(2, 3),
  type = "h", title = TRUE, ...)

Arguments

ffmObj

an object of class ffm produced by fitFfm

isPlot

logical. If FALSE no plots are displayed.

isPrint

logical. if TRUE, the time series of the computed factor model values is printed. default is FALSE,

myColor

length 2 vector specifying the plotting color for t-stats plot and for barplot respectively. default is c("black", "cyan")

lwd

line width relative to the default. default is 2.

digits

an integer indicating the number of decimal places to be used for rounding. default is 2.

z.alpha

critical value corresponding to the confidence interval. default is 1.96 i.e 95% C.I

layout

numeric vector of length 2 or 3 giving the number of columns, rows, and pages (optional) in the xyplot of t-statistics. default is c(2,3).

type

character. Type of the xyplot of t-statistics; "l" for lines, "p" for points, "h" for histogram like (or high-density) vertical lines and "b" for both. Deafault is "h".

title

logical. if TRUE, the plots will have the main tiltle. default is TRUE.

...

potentially further arguments passed.

Value

ffmTstats plots the t-stats and significant t-stats values if isPlot is TRUE and returns a list with following components:

tstats

an xts object of t-stats values.

z.alpha

critical value corresponding to the confidence interval.

Author(s)

Avinash Acharya and Doug Martin

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
 
 data("factorDataSetDjia5Yrs")

#Fit a Ffm with style factors only
 require(factorAnalytics)
 fit <- fitFfm(data = factorDataSetDjia5Yrs,exposure.vars = c("MKTCAP","ENTVAL","P2B","EV2S"),
             date.var = "DATE", ret.var = "RETURN", asset.var = "TICKER", fit.method="WLS",z.score = TRUE)

#Compute time series of t-stats and number of significant t-stats 
 stats = ffmTstats(fit, isPlot = TRUE, lwd = 2, myColor = c("blue", "blue"), z.alpha =1.96)

fit1 <- TestfactorAnalytics::fitFfm(data=factorDataSetDjia5Yrs, asset.var="TICKER", ret.var="RETURN", 
               date.var="DATE", exposure.vars=c("SECTOR","MKTCAP","ENTVAL","P2B"), addIntercept=TRUE)
#Compute time series of t-stats and number of significant t-stats 
 stats = ffmTstats(fit1, isPlot = TRUE, z.alpha =1.96) 
               
# Fit a SECTOR+COUNTRY+Style model with Market
# Create a COUNTRY column with just 3 countries

 factorDataSetDjia5Yrs$COUNTRY = rep(rep(c(rep("US", 1 ),rep("INDIA", 1),
                                       rep("GERMANY", 1 )), 10), 60)
 exposure.vars= c("SECTOR", "COUNTRY","P2B", "MKTCAP")
 
 fit.MICM <- TestfactorAnalytics::fitFfm(data=factorDataSetDjia5Yrs, asset.var="TICKER", ret.var="RETURN", 
                   date.var="DATE", exposure.vars=exposure.vars, addIntercept=TRUE)
 stats = ffmTstats(fit.MICM, isPlot = TRUE, z.alpha =1.96)

AvinashAcharya/Test_factorAnalytics documentation built on May 5, 2019, 9:22 a.m.