今回はLASSOとリッジ回帰についてです。 パッケージは「glmnet」、「lars」、「lasso2」で実行できます。 glmnetとlarsの作者はFriedman、Hastie、Efron、Tibshiraniと有名な先生ですが、lasso2の作者は知らないです。。 内容もほぼ一緒なので、LASSOをするときはglmnet一択で良いと思います。 まずは使用例から。。。 データはLARSパッケージにあるdiabetesを使います。 このデータである結果変数y(中性脂肪?)をx(性別や血圧など)によって予測するモデルを作ります。 まずは単純な線形回帰をします。 library(lars) library(glmnet) data(diabetes) Linear <- lm(diabetes$y ~ diabetes$x) Linear$coefficients これが推定結果です。 (
![LASSO and Ridge regression - データサイエンティスト上がりのDX参謀・起業家](https://cdn-ak-scissors.b.st-hatena.com/image/square/4bcda6466e5d04b43013f0826c6d568973bf204d/height=288;version=1;width=512/https%3A%2F%2Fcdn-ak.f.st-hatena.com%2Fimages%2Ffotolife%2Fi%2Fisseing333%2F20110309%2F20110309203644.png)