【问题标题】:How to calculate P values in ridge regression in R?如何计算R中岭回归中的P值?
【发布时间】:2015-08-13 19:23:26
【问题描述】:

以下是 MASS 包的 ?lm.ridge 中的示例:

> data(longley) # not the same as the S-PLUS dataset
> names(longley)[1] <- "y"
> lm.ridge(y ~ ., longley)
                        GNP    Unemployed  Armed.Forces    Population          Year      Employed 
2946.85636017    0.26352725    0.03648291    0.01116105   -1.73702984   -1.41879853    0.23128785 
> plot(lm.ridge(y ~ ., longley,
+               lambda = seq(0,0.1,0.001)))
> select(lm.ridge(y ~ ., longley,
+                lambda = seq(0,0.1,0.0001)))
modified HKB estimator is 0.006836982 
modified L-W estimator is 0.05267247 
smallest value of GCV  at 0.0057 

如何计算 P 值或置信区间,就像我在通常的线性回归摘要中得到的那样。

【问题讨论】:

  • 这是交叉验证的问题。

标签: r statistics regression


【解决方案1】:

就我而言,MASS::lm.ridge 不会为您的系数计算 p 值。但是,您可以使用 ridge 包中的 linearRidge 函数。请参见以下示例:

data(longley) 
names(longley)[1] <- "y"

library(ridge)
mymod <- linearRidge(y ~ ., longley)

> summary(mymod)

Call:
linearRidge(formula = y ~ ., data = longley)


Coefficients:
               Estimate Scaled estimate Std. Error (scaled) t value (scaled) Pr(>|t|)    
(Intercept)  -1.247e+03              NA                  NA               NA       NA    
GNP           4.338e-02       1.670e+01           3.689e+00            4.526  6.0e-06 ***
Unemployed    1.184e-02       4.286e+00           2.507e+00            1.710   0.0873 .  
Armed.Forces  1.381e-02       3.721e+00           1.905e+00            1.953   0.0508 .  
Population   -2.831e-02      -7.627e-01           5.285e+00            0.144   0.8853    
Year          6.566e-01       1.211e+01           2.691e+00            4.500  6.8e-06 ***
Employed      6.745e-01       9.175e+00           4.996e+00            1.836   0.0663 .  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Ridge parameter: 0.01046912, chosen automatically, computed using 2 PCs

Degrees of freedom: model 3.67 , variance 3.218 , residual 4.123 

使用summary,您将获得熟悉的表格,其中包含您的 p 值和重要性!

【讨论】:

  • 这正是我想要的。谢谢。
  • 如何从这个包中获得 GCV,就像使用 lm.ridge 一样?
  • @SideshowBob 据我所知linearRidge 不计算广义交叉验证指标。为什么你还需要它?您可以使用任何其他包来执行您想要的任何类型的交叉验证(例如使用 caret 包)。
  • 有谁知道为什么山脊一直是removed from the CRAN repository
  • @Arne 和其他人来晚了,山脊包已在去年被 Steffen Moritz 采用并重新添加到 CRAN。
猜你喜欢
  • 2016-08-24
  • 2019-07-03
  • 2017-12-05
  • 1970-01-01
  • 2018-08-31
  • 1970-01-01
  • 2016-01-29
  • 2020-10-15
  • 2010-10-09
相关资源
最近更新 更多