O'Reilly logo

Practical Predictive Analytics by Ralph Winters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Printing out the possible coefficients based on Lambda

Using some of the lambda values, you can print out the different coefficients for each model.

This will also help you choose a lambda value that is good for your model:

coef(mod.result,s=0.1957000)     #  4 of 5 coefficient are at 0, too much shrinkagecoef(mod.result,s=0.0131800)     #  only 1 coefficient is set to 0coef(mod.result,s=0.0120100)     #   All coefficients are includedcoef(mod.result,s=0.01)

Using a lambda of .01 will use all of the variables, so let's print out the coefficients using that value:

> coef(mod.result,s=0.01) 
7 x 1 sparse Matrix of class "dgCMatrix" 
                                         1 
(Intercept)       -17.57297008856023268208df.Duration -0.000962546 df.TreatmentB -0.33638216397784859168 df.TreatmentP 2.82134076268210698402 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required