我试图了解因素在R中的确切作用。假设我想使用R中的一些样本数据进行回归:
> data(CO2)
> colnames(CO2)
[1] "Plant" "Type" "Treatment" "conc" "uptake"
> levels(CO2$Type)
[1] "Quebec" "Mississippi"
> levels(CO2$Treatment)
[1] "nonchilled" "chilled"
> lm(uptake ~ Type + Treatment, data = CO2)
Call:
lm(formula = uptake ~ Type + Treatment, data = CO2)
Coefficients:
(Intercept) TypeMississippi Treatmentchilled
36.97 -12.66 -6.86
我了解这一点,TypeMississippi
并将Treatmentchilled
其视为布尔值:对于每一行,初始摄取为36.97
,12.66
如果它是密西西比州的类型并且6.86
是冷藏的,我们就减去它。我在理解以下内容时遇到了麻烦:
> lm(uptake ~ Type * Treatment, data = CO2)
Call:
lm(formula = uptake ~ Type * Treatment, data = CO2)
Coefficients:
(Intercept) TypeMississippi
35.333 -9.381
Treatmentchilled TypeMississippi:Treatmentchilled
-3.581 -6.557
将两个因子相乘在一起是什么意思lm
?