【问题标题】:Significant Quadratic terms - linear regression - R [closed]重要的二次项 - 线性回归 - R [关闭]
【发布时间】:2013-10-17 19:42:56
【问题描述】:

我得到了以下数据:

我被告知首先拟合二次模型。

 > time = c(10,20,15,11,11,19,11,13,17,18,16,16,17,18,10)
 > experience = c(24,1,10,15,17,3,20,9,3,1,7,9,7,5,20)
 > fit = lm (time ~ experience + I(experience^2))
> summary(fit)

Call:
lm(formula = y ~ x + I(x^2))

Residuals:
    Min      1Q  Median      3Q     Max 
-1.8287 -0.8300  0.5054  0.7476  1.1713 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) 20.091108   0.724705  27.723    3e-12 ***
x           -0.670522   0.154706  -4.334 0.000972 ***
I(x^2)       0.009535   0.006326   1.507 0.157605    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.091 on 12 degrees of freedom
Multiple R-squared:  0.9162,    Adjusted R-squared:  0.9022 
F-statistic: 65.59 on 2 and 12 DF,  p-value: 3.465e-07

那里一切似乎都很好。

我的模特是

y = 20.091-.671x+.0095x^2

绘制它:

> x = seq(0,25, by = .1)
> y = fit$coefficient[1]+fit$coefficient[2]*x+fit$coefficient[3]*x^2
> lines(x,y)

再次,一切似乎都很好。

然后我被告知要测试二次项在 a = .1 显着性水平上是否显着。

所以我愿意

> fit1 = lm (time ~ experience + I(experience^2))
> fit2 = lm(time~experience)
> anova(fit2, fit1)

Analysis of Variance Table

Model 1: time ~ experience
Model 2: time ~ experience + I(experience^2)
  Res.Df    RSS Df Sum of Sq      F Pr(>F)
1     13 16.984                           
2     12 14.280  1    2.7037 2.2719 0.1576

所以我的二次项的 F 值为 2.27。对应的概率为 0.1576。 .1576 > .1 因此二次项在 a = .1 处显着

但是我的教授指出,我们应该发现二次项对我们的模型来说是微不足道的。我在这里做错了什么?

【问题讨论】:

  • 这应该移到 stats.stackexchange.com。你的教授是正确的
  • “显着”表示小于 alpha。所以你的结果是微不足道的,正如你的教授所说的那样。
  • 那么值 .1576 到底是什么意思?用简单的英语
  • 这个问题似乎跑题了,因为它是关于统计的:它属于 CrossValidated

标签: r statistics linear-regression


【解决方案1】:

您没有做的是构造正交多项式项。 R 中的 poly() 函数就是为此目的而设计的。

 time = c(10,20,15,11,11,19,11,13,17,18,16,16,17,18,10)
 experience = c(24,1,10,15,17,3,20,9,3,1,7,9,7,5,20)
 fit = lm (time ~ poly(experience, degree=2))
 summary(fit)
#--------------
Call:
lm(formula = time ~ poly(experience, degree = 2))

Residuals:
    Min      1Q  Median      3Q     Max 
-1.8287 -0.8300  0.5054  0.7476  1.1713 

Coefficients:
                              Estimate Std. Error t value Pr(>|t|)    
(Intercept)                    14.8000     0.2817  52.544 1.48e-15 ***
poly(experience, degree = 2)1 -12.3861     1.0909 -11.354 8.94e-08 ***
poly(experience, degree = 2)2   1.6443     1.0909   1.507    0.158    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.091 on 12 degrees of freedom
Multiple R-squared:  0.9162,    Adjusted R-squared:  0.9022 
F-statistic: 65.59 on 2 and 12 DF,  p-value: 3.465e-07

您的 F 统计量并非特定于二次项,而是真正将空模型与两项模型进行比较。

【讨论】:

  • 使用 poly(x,2),您将如何使用 Lrts 测试 x 和 x^2 的显着性,而不测试空模型与同时具有这两个项的模型?
  • 您需要用更精确的语言解释“用 Lrts 测试 x 和 x^2 的重要性”是什么意思。你有 F 检验,它是 LR 检验,你有两个 t 检验,它们是 Wald 检验。度数 = 2 的 Wald 检验应与将此模型与以 x 作为协变量的一度(非多边形)模型进行比较的方差分析一致。
猜你喜欢
  • 2016-02-16
  • 1970-01-01
  • 2022-09-09
  • 2018-09-04
  • 2015-04-06
  • 2016-01-17
  • 2020-05-17
  • 2016-11-27
  • 2022-11-25
相关资源
最近更新 更多