shokru / mlfactor.github.io

Website dedicated to a book on machine learning for factor investing
202 stars 96 forks source link

Features in the data #71

Open qucqu opened 3 years ago

qucqu commented 3 years ago

In 5.1.3 Illustration, I try to use your code and data to compute Lasso as you did in your book:

library(glmnet) y_penalized <- data_ml$R1M_Usd # Dependent variable x_penalized <- data_ml %>% # Predictors dplyr::select(all_of(features)) %>% as.matrix() fit_lasso <- glmnet(x_penalized, y_penalized, alpha = 1) # Model alpha = 1: LASSO

in dplyr::select(all_of(features)) %>% as.matrix(), since there is no "features" in your data, I cannot repeate your compution. Is the data in github is not the one you used in your book?

Thanks and regards, Mike

shokru commented 3 years ago

Dear Mike,

sorry for the inconvenience. The set of features is defined in Chapter 2 as: _features <- colnames(dataml[3:95])

With this it should work. Best,

Guillaule

qucqu commented 3 years ago

Dear Guillaule,

Many thanks for your quick response! It really solve my problem.

With Best Regards, Mike