我想测试主效应的重要性,双向交互以及以下数据帧的三向交互 - 具体来说,
主要影响=自我监控(高与低),论证(强与弱),来源(有吸引力与专家)
双向互动=自我监控参数,自我监控来源,参数*来源
三向互动=自我监控参数来源
这是代码:
data<-data.frame(Monitor=c(rep("High.Self.Monitors", 24),rep("Low.Self.Monitors", 24)),
Argument=c(rep("Strong", 12), rep("Weak", 12), rep("Strong", 12), rep("Weak", 12)),
Expert.Source=c(4,3,4,5,2,5,4,6,3,4,5,4,3,5,3,2,6,4,4,3,5,3,2,3,3,5,5,4,3,2,1,5,3,4,3,4,5,6,4,7,6,7,5,6,4,6,7,5),
Attractive.Source=c(4,4,2,3,5,3,2,3,4,3,2,4,5,5,7,5,6,4,3,5,6,7,7,6,5,4,3,2,4,6,2,4,4,3,4,3,6,4,4,2,4,5,4,3,4,2,3,4))
data$Monitor<-as.factor(data$Monitor)
data$Argument<-as.factor(data$Argument)
我可以进行双向互动和主要效果,但我无法进行三向互动,如下所示:
anova(lm(Expert.Source ~ Monitor+Argument+Monitor*Argument, data))
anova(lm(Attractive.Source ~ Monitor+Argument+Monitor*Argument, data))
我猜想这可以通过简单的数据结构或者我不知道的R包来解决。
答案 0 :(得分:1)
我不完全确定你得到了什么错误。我附上了我使用的代码和我得到的结果。我能够使用三向互动。对于更大的数据FYI,这要困难得多。一些额外的信息/错误将帮助我们找到答案。
data<-data.frame(Monitor=c(rep("High.Self.Monitors", 24),rep("Low.Self.Monitors", 24)),
Argument=c(rep("Strong", 12), rep("Weak", 12), rep("Strong", 12), rep("Weak", 12)),
Expert.Source=c(4,3,4,5,2,5,4,6,3,4,5,4,3,5,3,2,6,4,4,3,5,3,2,3,3,5,5,4,3,2,1,5,3,4,3,4,5,6,4,7,6,7,5,6,4,6,7,5),
Attractive.Source=c(4,4,2,3,5,3,2,3,4,3,2,4,5,5,7,5,6,4,3,5,6,7,7,6,5,4,3,2,4,6,2,4,4,3,4,3,6,4,4,2,4,5,4,3,4,2,3,4))
data$Monitor<-as.factor(data$Monitor)
data$Argument<-as.factor(data$Argument)
anova(lm(Expert.Source ~ Monitor+Argument+Monitor*Argument, data))
anova(lm(Attractive.Source ~ Monitor+Argument+Monitor*Argument*Expert.Source, data))
Df Sum Sq Mean Sq F value
Monitor 1 5.333 5.3333 4.3392
Argument 1 16.333 16.3333 13.2888
Expert.Source 1 15.227 15.2269 12.3886
Monitor:Argument 1 4.152 4.1516 3.3778
Monitor:Expert.Source 1 0.230 0.2301 0.1872
Argument:Expert.Source 1 0.023 0.0234 0.0191
Monitor:Argument:Expert.Source 1 1.454 1.4538 1.1828
Residuals 40 49.164 1.2291