2014-01-11 331 views
0

当我运行anova函数时,我正在从以下数据集中收到此错误消息:summary(aov(Site~Chlo,data=alldata))。数据集保存在txt文件下。运行anova时出现错误消息

Error in levels(x)[x] : only 0's may be mixed with negative subscripts 

In addition: Warning messages: 

1: In model.response(mf, "numeric") : 
    using type = "numeric" with a factor response will be ignored 

2: In Ops.factor(y, z$residuals) : - not meaningful for factors 

Year Site Chlo DAC PARD SST 
2003 Seych 2.95 0.24 -39.36 0.40 
2003 Brazil -2.35 -0.14 22.97 4.03 
2003 Indo 0.42 0.04 6.82 0.60 
2004 Seych 0.20 0.02 -2.30 -0.63 
2004 Brazil -0.22 -0.01 -10.28 -1.22 
2004 Indo 0.32 0.03 15.82 -1.72 

这是背后的原因吗?

+0

我很确定你想'Chlo〜Site'而不是'Site〜Chlo'。您应该阅读有关公式语法的文档。因变量在左侧,RHS的预测因子。 – Roland

回答

1

我假设你想测试Chlo是否与Site不同。所以Chlo属于LHS和Site在公式中的RHS。与您的数据:

DF <- read.table(text="Year Site Chlo DAC PARD SST 
2003 Seych 2.95 0.24 -39.36 0.40 
2003 Brazil -2.35 -0.14 22.97 4.03 
2003 Indo 0.42 0.04 6.82 0.60 
2004 Seych 0.20 0.02 -2.30 -0.63 
2004 Brazil -0.22 -0.01 -10.28 -1.22 
2004 Indo 0.32 0.03 15.82 -1.72", header=TRUE) 

summary(aov(Chlo~Site, data=DF)) 
#   Df Sum Sq Mean Sq F value Pr(>F) 
#Site   2 8.247 4.124 2.043 0.275 
#Residuals 3 6.055 2.018 

所以,它不是显著不同,但如果n是小没有太多的权力,并进行方差分析并没有真正意义。

+0

你假设正确!这张表有更多的信息,这一年会持续到2012年。你会推荐哪一种测试? – user3170629

+0

由于您有时间序列数据,您可能需要做一些时间序列/回归分析。但是,这是题外话题。做一些研究或咨询统计学家。你也可以在stats.stackexchange.com上提问。 – Roland

相关问题