使用dplyr进行F检验方差

时间:2019-02-16 02:52:19

标签: r dplyr

我的目标是评估零模型,即种子云和非种子云的降雨变化相同。

cloudS_data <- read.csv('http://faculty.cord.edu/reber/data/205/CR1/CloudSeeding.csv')
cloudS_data

grpCloudsData <- cloudS_data %>% group_by(treatment)
grpCloudsData %>% summarise(rainfall = var(rainfall))

谢谢

1 个答案:

答案 0 :(得分:2)

F-test of equality of variances对正态性假设非常敏感

Bartlett's test对正态性假设也很敏感。

I社会科学中最普遍的方差同质性检验是Levene's test,它是巴特利特检验的替代方法。与正常情况相比,Levene检验不如Bartlett检验敏感。如果您有充分的证据表明您的数据确实来自正态分布或接近正态分布,那么Bartlett的测试将具有更好的性能。source

Brown–Forsythe test针对多种类型的非正常数据提供了良好的鲁棒性,同时又保持了良好的统计能力。

所以让我们使用Brown–Forsythe测试:

library(onewaytests)
bf.test(rainfall  ~ treatment, data = cloudS_data)

结果:

Brown-Forsythe Test (alpha = 0.05) 
------------------------------------------------------------- 
  data : rainfall and treatment 

  statistic  : 3.992982 
  num df     : 1 
  denom df   : 33.85525 
  p.value    : 0.05377346 

  Result     : Difference is not statistically significant. 
------------------------------------------------------------- 

和F检验:

var.test(rainfall  ~ treatment, data = cloudS_data)

结果:

    F test to compare two variances

data:  rainfall by treatment
F = 5.4633, num df = 25, denom df = 25, p-value = 6.695e-05
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
  2.44959 12.18487
sample estimates:
ratio of variances 
          5.463326 

收入测试:

lawstat::levene.test(cloudS_data$rainfall , cloudS_data$treatment, location = "mean")

结果:

    Classical Levene's test based on the absolute deviations from the mean ( none not applied because
the location is not set to median )

data:  cloudS_data$rainfall
Test Statistic = 6.0876, p-value = 0.01708