我正在测试来自包C.test
的{{1}}函数,该函数对偏差方差执行Cochran C测试。我在城市周围的不同站点上有这个SO2测量数据框,它有3列:站,日和值。
这个函数的问题是它需要一个GAD
对象,我不太明白你是如何构建一个,但我只是这样做:
lm
这里显而易见的问题(正如Cross Validated中提到的那些人,我已经删除了那篇帖子)是我得到的p值大于1,这是不可能的。另一个问题是,当函数不是具有最大方差的那个时,该函数正在测试28079057站的偏离方差。
如果我使用> C.test(lm(data = testSO2E1, value ~ estacion))
Cochran test of homogeneity of variances
data: lm(data = testSO2E1, value ~ estacion)
C = 0.13123, n = 31, k = 10, p-value = 1.066
alternative hypothesis: Group 28079057 has outlying variance
sample estimates:
28079004 28079008 28079017 28079018 28079024 28079035 28079036 28079038 28079040
16.8516 16.0559 17.9118 22.5828 30.0516 22.2366 23.6731 27.0452 26.5118
28079057
30.6516
包中的Cochran.test
函数,它可以正常运行:
outliers
当我像其文档中包含的示例一样使用> cochran.test(value~Estacion,testSO2E1)
Cochran test for outlying variance
data: value ~ Estacion
C = 0.26268, df = 31, k = 10, p-value = 2.285e-06
alternative hypothesis: Group 28079036 has outlying variance
sample estimates:
28079004 28079008 28079017 28079018 28079024 28079035 28079036 28079038 28079040
4.1032258 5.3784946 3.3118280 1.7913978 0.3118280 8.6064516 13.1397849 9.0258065 0.9569892
28079057
3.3956989
时,它可以正常工作,我从两个函数中获得相同的结果,但我不知道有什么不同:
C.test
我是否错误地创建了data(rohlf95)
## rohlf95 has 4 columns (cage, mosquito, measure, wing), we are testing if
## one group of mosquitos have outlying variance
cg <- as.fixed(rohlf95$cages)
mq <- as.random(rohlf95$mosquito)
model <- lm(wing ~ cg + mq%in%cg, data = rohlf95)
C.test(model)
个对象?变量lm
有什么作用?我是否需要类似的东西来测试SO2测量?
以下是我正在测试的数据的链接:https://drive.google.com/open?id=0B-0fUAdfgHYzUjcyVHhBcl9rWlk
这里是函数C.test {GAD}的代码:
cg,mq
答案 0 :(得分:0)
分别查看cochran.test()或pcochran()的代码。
cochran.test()中的p值计算如下:
pval <- 1 - pcochran(value, df, k)
和pcochran函数的代码是
function (q, n, k) {
f <- (1/q - 1)/(k - 1)
p <- 1 - pf(f, (n - 1) * (k - 1), n - 1) * k
p[p < 0] <- 0
p[p > 1] <- 1
return(p)
}
当“计算的p值”> 1且<0时,它只是将p值设置为0或1,这在GAD包中没有完成。
问候