R中最小效应假设(非中心f分布)的功率计算

时间:2016-02-02 12:20:41

标签: r

在工作中,我被要求计算Wald检验统计量的统计功效。我们正在测试1.54%解释方差的零假设,这就是为什么我们所比较的F分布是非中心的。

现在我被告知首先在零假设下计算显着性水平的临界F值(我们使用.05)。我在R中这样做了:

`groups <- 2
N <- 4440
PV <- 0.0154

min.eff.hyp <- function(N, groups=2, PV=.01, alpha=.05){
  df1 <- groups - 1 # numerator degrees of freedom
  df2 <- N-groups # denominator degrees of freedom
  ncp <- ((N-1)*PV)/(1-PV) # non-centrality parameter
  g <- (df1+ncp)^2/(df1+2*ncp) # adjusted df1
  k <- (df1+ncp)/df1 # to adjust for non-centrality
  crit.central <- qf(1-alpha,g,df2)
  crit.val <- crit.central * k
  return(paste('Kritischer F-Wert (PV=',PV,'): ',round(crit.val,3), sep = ''))
}

min.eff.hyp(N,groups,PV)`

然后我应该使用这个关键的F值来确定备选假设下的α'。 然后可以使用此α'来计算统计功效。

不幸的是,我不知道如何获得alpha'。我再次尝试使用R:     pf(crit.val,g,df2,ncp)

我认为,考虑到替代假设是正确的,这应该计算我的数据的概率。但事实上,我不知所措。我不知道如何在功率计算中实现非中心性,不知何故我找不到之前遇到过同样问题并且实际找到解决方案的人。

当我针对最小效应假设进行测试并因此与非中心分布进行比较时,如何计算测试的统计功效?

非常感谢你花时间帮助我!

问候, 玛利亚

1 个答案:

答案 0 :(得分:1)

我们可以使用以下各项来计算F检验统计量的统计功效:groups,个人N,显着性水平alpha和解释方差百分比{{ 1}}。

一种方法是将非中心F分布与估计的非中心性参数PV一起使用。如您的示例所示,另一种方法是使用调整后的中央F分布(Murphy et al. 2009)

仿真结果表明,第一种方法对NCP的估计更为准确。

power

非中心F分布的模拟:

>        theoretical  simulation  method_1   method_2
> Power    0.4631185      0.4647  0.460971  0.5521764
> F mean    4.518145    4.529506  4.497807          -
> PV       0.0089153   0.0089509         -          -
> NCP            3.5           -  3.479744          -

方法1(非中央F分布):

## Simulation to get PV and power
groups <- 2
N <- 500
alpha <- 0.05
ncp <- 3.5 #Non-Centrality Parameter

#simulated Sum of Squares for Model and Error
set.seed(1)
df1 <- groups - 1 #main effect degrees of freedom 
df2 <- N - groups #error degrees of freedom
SSM = SSE = rep(NA,10000)
for (i in 1:10000)
  {
    SSM[i] <- sum(rnorm(df1, mean=sqrt(ncp/df1))^2)
    SSE[i] <- sum(rnorm(df2)^2)
  }

#mean F
F <- SSM/df1 / (SSE/df2)
mean(F) #estimated
> 4.529506
(df1+ncp) / df1 / ((df2-2)/df2) #theoretical
> 4.518145

#PV: Percentage of explained Variance
PV <- SSM / (SSM + SSE)
mean(PV)
> 0.008950899
(ncp + df1) / (ncp + df1 + df2) #theoretical
> 0.008915272

#statistical Power
F_crit <- qf(1-alpha, df1, df2) #critical F value
sum(F > F_crit) / length(F) #estimated
> 0.4647
1 - pf(F_crit, df1, df2, ncp) #theoretical
> 0.4631185

方法2(调整后的中央F分布):

groups <- 2
N <- 500
alpha <- 0.05
PV <- 0.008950899
ncp <- NA

df1 <- groups - 1
df2 <- N - groups

#mean F
PV/df1 / ((1-PV) / df2)
> 4.497807

#estimated Non-Centrality Parameter
ncp <- (df2 - 2) * PV / (1-PV) - df1
> 3.479744

#estimated statistical power
F_crit <- qf(1-alpha, df1, df2) #critical F value
1 - pf(F_crit, df1, df2, ncp=ncp)
> 0.460971

方法1背后的代数(用于估计非中心性参数):

abc

abc

最后一个等于来自wikipedia的地方。

abc

相关问题