Book Image

Mastering R for Quantitative Finance

Book Image

Mastering R for Quantitative Finance

Overview of this book

Table of Contents (20 chapters)
Mastering R for Quantitative Finance
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Including multiple variables


One method to build a performance-prediction model could be using multiple variable regression models. A linear estimation should only include variables with minimal linear connection among them. As we have just seen, our explanatory variables are more or less independent of each other, which is great. It is bad news, though, that these variables individually also have low correlation with the dependent variable, TRS.

To get the best linear estimation, we may choose from several methods. One option is to first include all variables and ask R to drop step by step the one with the lowest significance (step-wise method). Under another widely used method, R could start with one variable only and enter stepwise the next one with the highest explanatory power (the backward method). Here, we picked the latter, as the first method could not end with a significant model:

library(MASS)
vars <- colnames(d_filt)
m <- length(vars)
lin_formula <- paste(vars[m], paste...