【问题标题】:Does R's drop1 account for the non-interaction terms when there are both interaction terms and non-interaction terms in the model?当模型中同时存在交互项和非交互项时,R 的 drop1 是否考虑了非交互项?
【发布时间】:2013-03-15 00:54:31
【问题描述】:

我的问题在标题中。我不确定是否考虑了非交互项,因为 drop1 的输出不包括它们,而只包括交互项。代码和输出如下:

> temp = lm(auto.mpg.data$mpg ~ auto.mpg.data$weight + auto.mpg.data$model_year + auto.mpg.data$origin + auto.mpg.data$weight:auto.mpg.data$model_year + auto.mpg.data$weight:auto.mpg.data$origin + auto.mpg.data$model_year:auto.mpg.data$origin)
> drop1(temp, test="F")
Single term deletions

Model:
auto.mpg.data$mpg ~ auto.mpg.data$weight + auto.mpg.data$model_year + 
        auto.mpg.data$origin + auto.mpg.data$weight:auto.mpg.data$model_year + 
    auto.mpg.data$weight:auto.mpg.data$origin + auto.mpg.data$model_year:auto.mpg.data$origin
                                              Df Sum of Sq    RSS    AIC F value    Pr(>F)    
<none>                                                     3769.8 908.83                      
auto.mpg.data$weight:auto.mpg.data$model_year  1   300.625 4070.4 937.37 31.1807 4.407e-08 ***
auto.mpg.data$weight:auto.mpg.data$origin      1    94.557 3864.3 916.69  9.8074  0.001869 ** 
auto.mpg.data$model_year:auto.mpg.data$origin  1     0.027 3769.8 906.83  0.0028  0.958085    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 `enter code here`

【问题讨论】:

  • 忠告,在为线性模型创建公式时不要使用data$column。使用lm(mpg~(weight+model_year+origin)^2, data = auto.mpg.data)获取相同的模型。
  • 不太清楚你所说的“帐户”是什么意思。 drop1 只是删除每个术语并将没有它的模型与完整模型进行比较。
  • 我所说的“帐户”是指单例项 weight/model_year/origin 似乎没有被删除,因为它们在输出中没有自己的行。每个交互项都被删除并在输出中“解释”。感谢您提供有用的建议和链接。我在那里找到了答案:drop1 的第二个选项称为范围,您可以在其中使用公式指定添加和删除要考虑哪些术语。

标签: r interaction


【解决方案1】:

是的,如果存在交互,drop1 函数会考虑较低级别的术语。如果预测变量是交互的一部分,则不会被丢弃。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-17
    • 2012-10-18
    • 2021-09-23
    • 2010-12-19
    • 2022-11-29
    • 1970-01-01
    • 2013-04-16
    相关资源
    最近更新 更多