我在一个大型数据集 n=1918, p=85 上运行套索回归,回归识别为重要的系数 - 当实际放入线性模型时 - 非常微不足道。另一方面,套索认为非常重要的解释性“模型”变量具有接近 0 的系数并且没有选择它们。进入 LARS 的数据帧已经被缩放。关于为什么会发生这种情况的任何想法?下面是 LARS 可能选择的示例,以及我使用完全相同的数据集创建的具有实际良好解释变量的模型。
更新:我注意到套索正在选择我所有的温度变量并为它们分配相对较高的系数(> 1),而所有其他变量都介于 0 和 1 之间。不知道为什么会发生这种情况。
signif.coefs <- function(lasso, threshold=1){
coefs <- coef(lasso)
signif <- which(abs(coefs[nrow(coefs),]) > threshold)
return(setNames(coefs[nrow(coefs),signif], signif))
}
signif.coefs(lasso)
4 45
4.855257 -3.020055
lm(response ~ SP.MTMEAN + YEAR, data=df, na.action=na.pass) ###Terrible Lasso Chosen Model
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.16710 0.07190 -2.324 0.02022 *
SP.MTMEAN 0.09889 0.02313 4.275 2.01e-05 ***
YEAR 0.14097 0.04580 3.078 0.00211 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.9903 on 1915 degrees of freedom
Multiple R-squared: 0.01678, Adjusted R-squared: 0.01576
F-statistic: 16.34 on 2 and 1915 DF, p-value: 9.167e-08
###variables chosen by me with model output from same data frame as above
lm(response~log1p.PTL_RESULT+log1p.NTL_RESULT+log1p.PH_RESULT+log1p.EPI.T+SU.MPPT, data=df, na.action=na.pass)
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.01200 0.01972 0.608 0.54301
log1p.PTL_RESULT 0.20672 0.03104 6.660 3.58e-11 ***
log1p.NTL_RESULT 0.21219 0.03335 6.362 2.49e-10 ***
log1p.PH_RESULT 0.15543 0.02543 6.113 1.18e-09 ***
log1p.EPI.T 0.09869 0.02189 4.508 6.93e-06 ***
SU.MPPT -0.06002 0.02135 -2.811 0.00499 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.8596 on 1912 degrees of freedom
Multiple R-squared: 0.2603, Adjusted R-squared: 0.2583
F-statistic: 134.5 on 5 and 1912 DF, p-value: < 2.2e-16