今回は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 これが推定結果です。 (