Learn R Programming

bdrift (version 1.2.2)

BDA: Beta Drift Anaylsis

Description

BDA performs a range of parameter instability diagnostics for financial multi-factor models and returns data frames containing the drifting parameters and their standard errors, a list of summary statistics and an overview plot for each factor.

Usage

BDA(data, spec, horizon = round(nrow(data) * 0.5) - 1, min.hor = 21, max.hor = 750, family = gaussian, doplot = TRUE, ...)

Arguments

data
an xts object containing all relevant time series. Please note that BDA assumes that the data is ordered so that the most recent data is at the tail of the matrix.
spec
contains the formula for the baseline model.
horizon
the time period for which the paramters should be estimated. (e.g. 250 for a year, assuming daily data). By default, half of the data length is used.
min.hor
the minimum horizon used in the analysis, by default one month, assuming daily data (21 obs if available).
max.hor
the maximum horizon used in the analysis, by default three years, assuming daily data (750 obs if available)
family
type of regression family passed to the glm function. For further details on family types refer to family. Please note that at this point the built-in plotting does not support all families.
doplot
logical. If TRUE, the function returns diagnostic plots for each parameter.
...
aditional commands passed to the glm function.

Value

a list with 8 elements:
CALL
function call
base.model
baseline model
tdrift
xts matrix containing historical estimates of baseline model
tdrift.se
xts matrix containing historical standard errors of baseline model
hdrift
matrix containing estimates of baseline model with varying horizon lengths
hdrift.se
matrix containing standard errors of baseline model with varying horizon lengths
jackknife
jackknife procedure of object class lm.influence
sumstats
list containing various summary statistics

Details

BDA performs a threefold analyis of a user-specified baseline model. First, BDA performs a rolling regression across the entire data frame where horizon determines the regression window size. The function includes all rolling parameter estimates and standard errors in the output, so users can access them using $tdrift and $tdrift.se respectively.

Second, BDA estimates the baseline model parameters with estimation windows of varying length from (min.hor to max.hor). Users can access the resulting parameter estimates and standard errors using $hdrift and $hdrift.se respectively.

Third, BDA checks the baseline model for observations that have a noteworthy impact on the parameter estimate.

For further details on the summary statistics output and plotting, please reference summary.BDA and plot.BDA respectively.

Although BDA was primarily developed to analyze financial multi-factor models, it is capable to analyze any model fit, as long as the underlying data is of class xts. However, BDA was developed with large datasets in mind, so that very small datasets might produce errors or non-sensical results.

Examples

Run this code
## Not run: 
# ###################################################
# ####   3-Factor Stock Example: ExxonMobil      ####
# ###################################################
# 
# results1 <- BDA(data = FFfactors, 
#                 spec = (XOM~Mkt.RF + SMB + HML),
#                 horizon = 250, doplot = TRUE)
# 
# ###################################################
# #### 5-Factor Active Fund Example: BlackRock   ####
# ###################################################
# 
# results2 <- BDA(data = FFfactors, 
#                 spec = (MDLRX~Mkt.RF + SMB + HML + RMW + CMA),
#                 horizon = 250, doplot = TRUE)
# 
# ###################################################
# ####   1-Factor Index Fund Example: Vanguard   ####
# ###################################################
# 
# results3 <- BDA(data = FFfactors, spec = (VOO~SP500),
#                 horizon = 250, doplot = FALSE)
# ## End(Not run)
###################################################
####        CRAN-compatible example            ####
###################################################

results <- BDA(data = FFfactors[nrow(FFfactors):(nrow(FFfactors)-300),], 
               spec = (VOO~SP500),horizon = 250, doplot = TRUE)
message("NOTE: This is a shortened example. Reference the manual for more complex examples")

Run the code above in your browser using DataLab