我有三个变量:
- 房屋销售量
- 月份(成对(
- 城市区域(N-W-E-S(
我想为变量创建一个具有交互作用的双向方差分析:
month <- c("1","1","1","1","2","2","2","2","3","3","3","3","4","4","4","4","5","5","5","5","6","6","6","6")
region <-c("1","2","3","4","1","2","3","4","1","2","3","4","1","2","3","4","1","2","3","4","1","2","3","4")
sales <-c(85, 107,61, 22, 40, 65, 58,51,60,41,45,27,15,30,68,63,28,3,57,12,36,21,10,16)
data <- cbind(sales, month, region)
data <- as.data.frame(data)
mod.aov <- aov(sales ~ month*region, data = data)
summary(mod.aov)
正如你所看到的:
> summary(mod.aov)
Df Sum Sq Mean Sq
month 5 6369 1273.7
region 3 1043 347.6
month:region 15 7854 523.6
R没有显示此模型的f值。为什么?
与这个例子相关的是,是否有可能(或有意义(对两个类别变量进行线性回归模型,作为它们之间相互作用的预测因子?任何见解都将不胜感激。Thx!
每个月和数据的组合只有一个观测值,无法估计月的影响:n=1的区域。
data = data.frame(sales,month,region)
table(data$month,data$region)
1 2 3 4
1 1 1 1 1
2 1 1 1 1
3 1 1 1 1
4 1 1 1 1
5 1 1 1 1
6 1 1 1 1
你可以粗略地解释为,Anova是方差分析,n=1意味着没有方差。因此,摘要不显示f值。
为了回答这个问题:
与此示例相关的是对两个分类变量执行线性回归模型预测因素与它们之间的相互作用?任何见解都是赞赏
是的,您可以做到这一点,例如,在这种情况下,如果每个月和区域组合有一个以上的复制,那么您基本上是在为每个月不同的区域效果建模。
我在另一篇文章中读到,模型已经饱和,因为没有足够的数据点来满足模型所需的所有自由度。
https://stats.stackexchange.com/questions/94078/why-do-i-not-get-a-p-value-from-this-anova-in-r