2013-03-15 84 views
1

我的问题在标题中。我不确定是否因为drop1的输出不包括它们而仅考虑了交互项,因此会计入非交互项。的代码,并输出如下:当模型中存在交互项和非交互项时,R的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` 
+1

一个忠告,不要在为线性模型创建公式时使用'data $ column'。使用'lm(mpg〜(weight + model_year + origin)^ 2,data = auto.mpg.data)'来获得相同的模型。 – mnel 2013-03-15 01:16:21

+2

这是值得阅读http://www.stats.ox.ac.uk/pub/MASS3/Exegeses.pdf – mnel 2013-03-15 01:20:31

+0

这是不是很清楚你的意思是“帐户”。 'drop1'只是放弃每一项,并将没有它的模型与完整模型进行比较。 – Ista 2013-03-15 01:29:59

回答

2

是的,drop1功能占较低级别的术语,如果相互作用的存在。如果预测变量是交互的一部分,则不会被删除。