R语言与LASSO回归和LAR算法

LASSO介绍

  • Tibshirani(1996)提出了LASSO(The Least Absolute Shringkage and Selectionator operator)算法
  • 通过构造一个一阶惩罚函数获得一个精炼的模型;通过最终确定一些指标(变量)的系数为零(岭回归估计系数等于0的机会微乎其微,造成筛选变量困难),解释力很强
  • 擅长处理具有多重共线性的数据,与岭回归一样是有偏估计

LASSO vs. 岭回归

岭回归与LASSO之间的本质区别

image

在几何意义上的区别(前者为LASSO回归,后者为岭回归)

image

LAR(最小角回归:后来成为LASSO回归的求解算法)

LAR(最小角回归:Least Angel Regression)

  • Efron于2004年提出的一种变量选择的方法,类似于向前逐步回归(Forward Stepwise)的形式。
  • 是LASSO REGRESSION的一种高效解法
  • 向前逐步回归(Forward Stepwise)不同在于,Forward Stepwise每次都是根据选择的变量子集,完全拟合出线性模型,计算出RSS,再设计统计量(如AIC)对较高的模型复杂度作出惩罚。
  • 而LAR是每次先找出和因变量相关度最高的那个变量,再沿着LSE的方向一点点调整这个predictor的系数。在这个过程中,这个变量和残差的相关系数会逐渐减小,等到这个相关性没有那么显著的时候,就要选出新的相关性最高的变量,然后重新沿着LSE的方向进行变动。而到最后,所有变量都被选中,就和LSE相同了。

Algorithm 3.2 Least Angle Regression

  1. Standardize the predictors to have mean zero and unit norm. Start with the residual r = y – y-, β,β,…, β = 0
  2. Find the predictor Xj most correlated with r
  3. Move βj from 0 towards its least-squares coeffcient <Xj, r>, until some other competitor Xk has as much correlation with the current residual as does Xj.
  4. Move βj and βk in the directin defined by their joint least squares coefficient of the current residual on (Xj, Xk), until some other competitor Xl has as much correlation with the current residual.
  5. Continue in this way until all p predictors have ben entered. After min(N-1, p) steps, we arrive at the full least-squares solution.

Algorithm 3.2a Least Angle Regression: Lasso Modification

  • 4a. if a non-zero coefficient hits zero, drop its variable from the active set of variables and recompute the current joint least squares direction.

LAR and LASSO

image

在R中使用LAR算法进行LASSO回归分析

继续使用longley数据集进行LASSO回归

image

进行LAR(最小角回归)

image

并打印LAR过程图

image

对得到的最小角回归进行summary

image

在数据结果中可知:在高亮步骤时,cp达到最小值(变量之间的多重共线性的程度达到最小值)。而此时为在全变量模型的基础上,-6 -5(去掉第六号变量和第五号变量)使模型达到最小的共线性程度。

即可作出精确的变量选择:y ~ 1 + 2 + 3 + 4 + 7(去掉 5, 6)

CP值的含义(Mallow’s Cp)

image

原线性模型的统计结果如下:

image

经过LAR算法进行LASSO回归分析,处理变量间的多重共线性后,更新原模型后的统计结果如下:

image

通过原线性模型和更新后的线性模型之间的对比可以发现:虽然,在进行了变量间的多重共线性处理之后,Multiple R-squared有所降低,但Residual standard error相应提高。而且,各个变量的显著性检验表现的更好。

  • 6
    点赞
  • 59
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值