比较 emmeans 估计与零分布。

huangapple go评论65阅读模式
英文:

comparing emmeans estimate to null distribution

问题

以下是翻译好的内容:

让我们假设我有这个模型:

set.seed(1)
df <- data.frame(y=rexp(500, .01), x=rep(c("A","B"),each=250), id=rep(seq(1,250),times=2))
mod <- lmer(y~ x + (1|id), data=df)

如果我计算每个 x 水平的平均效应,结果非常显著:

test(emmeans(mod, ~ x))
    
     x emmean   SE  df t.ratio p.value
 A   98.4 5.66 496  17.394  <.0001
 B   92.6 5.66 496  16.360  <.0001

因为它很可能在测试每个效应是否等于零。

为了使这些测试有意义,我想我需要使用自助法(bootstrapping)创建一个零分布。例如,对于 x=="A",可以使用以下方式创建零分布:replicate(10^4, mean(sample(df[df$x=="A","y"],n,rep=T))),然后将从 emmeans 得到的估计值与此分布中的值进行比较?

对于这个问题,使用 emmeans 的正确方法是什么?

英文:

Let's say I have this model

set.seed(1)
df &lt;- data.frame(y=rexp(500, .01), x=rep(c(&quot;A&quot;,&quot;B&quot;),each=250), id=rep(seq(1,250),times=2))
mod &lt;- lmer(y~ x + (1|id), data=df)

If I calculate the mean effect of each level of x, it is very significant

test(emmeans(mod, ~ x))

     x emmean   SE  df t.ratio p.value
 A   98.4 5.66 496  17.394  &lt;.0001
 B   92.6 5.66 496  16.360  &lt;.0001

because presumably it's testing each effect against zero.
To make these tests meaningful, I suppose I need to create a null distribution using bootstrapping. For example for x==&quot;A&quot;, replicate(10^4, mean(sample(df[df$x==&quot;A&quot;,&quot;y&quot;],n,rep=T))) and then compare the estimate from emmeans to the values in this distribution?

What is the correct approach to do this with emmeans?

答案1

得分: 2

代码部分不翻译。

以下是翻译好的部分:

  • 你不能在 emmeans 中这样做,因为没有办法将模拟分布的细节纳入其中。emmeans 的测试基于对 估计值 采样分布的正态近似,并且不使用其他分布。

  • 但是,你可以针对特定的 进行测试。例如,

test(emmeans(mod, "x"), null = 90)

或者如果你想要对各自的均值使用不同的空值

test(emmeans(mod, "x"), null = c(90, 80))

如果你使用与样本均值相等的空值,那么这些值恰好等于此示例中的EMM,并且你将获得P值为1。

英文:

You can't do it in emmeans because there is no way to incorporate the details of the simulated distribution. emmeans's tests are based on the normal approximation to sampling distribution of the estimate, and doesn't use any other distribution.

You can however test against a particular value. For example,

test(emmeans(mod, &quot;x&quot;), null = 90)

or if you want different null values for the respective means

test(emmeans(mod, &quot;x&quot;), null = c(90, 80))

If you use null values equal to the sample means, those are exactly equal to the EMMs in this example, and you will get P values of 1.

huangapple
  • 本文由 发表于 2023年6月2日 03:56:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76385281.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定