Stepwise variable selection

We can use stepwise variable selection (forward, backward, both) in predictive models using the stepAIC() function for feature selection.

This can be done by executing the following code:

> MultipleR.lm = lm(StockYPrice ~  
StockX1Price + StockX2Price + StockX3Price + StockX4Price,  
data=DataMR) 
> step <- stepAIC(MultipleR.lm, direction="both") 
> step$anova  

Here, we are using the dataset used for multiple regression as the input dataset. One can also use all-subsets regression using the leaps() function from the leaps package.

Variable selection by classification

We can use classification techniques such as decision tree or random forest to get the most significant predictors. Here we are using random forest (code is given) ...

Get Learning Quantitative Finance with R now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.