fmRsq {facmodCS} | R Documentation |
Factor Model R-Squared and Adj R-Squared Values
Description
Calcluate and plot the Factor Model R-Squared, Adjusted R-Squared for a portfolio of assets
Usage
fmRsq(
ffmObj,
rsq = TRUE,
rsqAdj = FALSE,
plt.type = 2,
digits = 2,
isPrint = TRUE,
isPlot = TRUE,
lwd = 2,
stripText.cex = 1,
axis.cex = 1,
title = TRUE,
...
)
Arguments
ffmObj |
an object of class |
rsq |
logical; if |
rsqAdj |
logical; if |
plt.type |
a number to indicate the type of plot for plotting Factor Model R-squared/Adj. R-squared values. 1 indicates barplot, 2 indicates time series xy plot. Default is 2. |
digits |
an integer indicating the number of decimal places to be used for rounding. Default is 2. |
isPrint |
logical. if |
isPlot |
logical. if |
lwd |
line width relative to the default. Default is 2. |
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. |
title |
logical. if |
... |
potentially further arguments passed. |
Value
fmRsq
returns the sample mean values and plots the time series of corresponding R squared values
and the Variance Inflation factors depending on the values of rsq
, rsqAdj
and VIF
.
The time series of the output values are also printed if isPrint
is TRUE
Author(s)
Avinash Acharya and Doug Martin
Examples
#Load the data
# Fundamental Factor Model
library(PCRA)
dateRange <- c("2006-01-31","2010-12-31")
stockItems <- c("Date", "TickerLast", "Return","Sector")
factorItems <- c("BP","Beta60M","PM12M1M")
facDatIT <- selectCRSPandSPGMI("monthly",
dateRange = dateRange,
stockItems = stockItems,
factorItems = factorItems,
outputType = "data.table")
asset.var="TickerLast"
ret.var="Return"
date.var = "Date"
exposure.vars= factorItems
asset.var="TickerLast"
ret.var="Return"
date.var = "Date"
spec1 <- specFfm(data = facDatIT,asset.var = asset.var, ret.var = ret.var,
date.var = date.var, exposure.vars = exposure.vars,weight.var = NULL,
addIntercept = TRUE, rob.stats = FALSE)
# fit a fundamental factor model
mdlFit <- fitFfmDT(spec1)
mdlRes <- extractRegressionStats(spec1,mdlFit)
fit.cross <- convert(SpecObj = spec1,FitObj = mdlFit, RegStatsObj = mdlRes)
#Calculate and plot the portfolio R-squared values
fmRsq(fit.cross)
#Plot and print the time series of Adj R-squared and VIF values
fmRsq(fit.cross, rsqAdj=TRUE, isPrint=TRUE, plt.type = 2)