【发布时间】: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