R中的ezANOVA和pairwise.t.test:输出 [英] ezANOVA and pairwise.t.test in R: output

查看:49
本文介绍了R中的ezANOVA和pairwise.t.test:输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 R 运行 ezANOVA,然后进行成对比较(pairwise.t.test...)

I've been running ezANOVA using R followed by pairwise comparisons (pairwise.t.test...)

一旦运行似乎没有包含输出(?),所以我有以下与此相关的问题:

There seems to be output not included(?) once run so I have the following questions in relation to this:

是否可以在 ezANOVA 中为重复测量生成均方误差,如果可以,如何生成?

Is it possible to generate Mean Square Error in ezANOVA for repeated measures and if so how?

以及如何在 pairwise.t.test 中为 df、t 和 SE 生成输出?

And also how does one generate output for df, t and SE in pairwise.t.test?

这对某些人来说可能很明显,但我查阅了书籍和在线资源,结果却是空洞的.

This may be very obvious to some but I've consulted books and online resources and come up empty.

一如既往地感谢您的时间.非常感谢.

Thanks as always for your time. It is very much appreciated.

更新:

计算ezANOVA输出中的MSE:

Calculating the MSE in ezANOVA output:

: > Exp2DModel
$ANOVA
        Effect DFn DFd        SSn       SSd          F            p p<.05       ges
1  (Intercept)   1  24 159.231492 3.1947477 1196.19955 5.453251e-22     * 0.9468257
2       Visual   2  48   1.603228 1.9257323   19.98069 4.861610e-07     * 0.1520259
3        Audio   4  96   1.831761 0.9966656   44.10934 5.788074e-21     * 0.1700122
4 Visual:Audio   8 192  14.230991 2.8253824  120.88409 1.010389e-70     * 0.6141057

: > Exp2DModel$ANOVA$SSd[2]/Exp2DModel$ANOVA$DFd[2]

MSE = [1] 0.04011942

MSE = [1] 0.04011942

推荐答案

也许 ezANOVA 帮助信息中的这些信息会有用.

Maybe this information from the help information for ezANOVA will be useful.

library(ez)
data(ANT)
rt_anova = ezANOVA(
    data = ANT[ANT$error==0,]
    , dv = rt
    , wid = subnum
    , within = .(cue,flank)
    , between = group
)

#Show the ANOVA and assumption tests.
print(rt_anova)

有关更多示例,请参阅此链接.

See this link for more examples.

帮助页面表明以下值是输出对象的一部分:

The help page indicates the following Values are part of the output object:

DFn          Degrees of Freedom in the numerator (a.k.a. DFeffect).
DFd          Degrees of Freedom in the denominator (a.k.a. DFerror).
SSn          Sum of Squares in the numerator (a.k.a. SSeffect).
SSd          Sum of Squares in the denominator (a.k.a. SSerror).
F            F-value.
p            p-value (probability of the data given the null hypothesis).
p<.05        Highlights p-values less than the traditional alpha level of .05.
ges          Generalized Eta-Squared measure of effect size (see in references below: Bakeman, 2005).
GGe          Greenhouse-Geisser epsilon.
p[GGe]       p-value after correction using Greenhouse-Geisser epsilon.
p[GGe]<.05   Highlights p-values (after correction using Greenhouse-Geisser epsilon) less than the traditional alpha level of .05.
HFe          Huynh-Feldt epsilon.
p[HFe]       p-value after correction using Huynh-Feldt epsilon.
p[HFe]<.05   Highlights p-values (after correction using Huynh-Feldt epsilon) less than the traditional alpha level of .05.
W            Mauchly's W statistic

这些列应该包含计算 MSE 所需的大部分原材料...虽然,我实际上不知道如何在重复测量方差分析中计算 MSE...

These columns should contain most of the raw material needed for calculating MSE... Though, I don't actually know how to calculate MSE in a repeated measures ANOVA...

据我所知 pairwise.t.test 提供只包含 p 值的输出.从帮助页面:

As far as I know pairwise.t.test provides output that contains only p-values. From the help page:

attach(airquality)
Month <- factor(Month, labels = month.abb[5:9])
pairwise.t.test(Ozone, Month)

我确实找到了这篇关于从成对中提取 t 值的帖子.t.test,这可能会有所帮助.本质上,在帖子中,修改了pairwise.t.test的代码.计算 p 值的行被注释掉(即 # 2 * pt(-abs(t.val), total.degf) 并添加一行以返回 t.val 而不是 p 值.您可以在该代码中看到计算了自由度和一个名为 se.diff 的对象,因此,您也应该能够通过修改代码来返回它们.

I did find this post on extracting t-values from pairwise.t.test, which may help. Essentially, in the post, the code for pairwise.t.test is modified. The line that calculates p-values is commented out (i.e. # 2 * pt(-abs(t.val), total.degf) and they add a line to return the t.val instead of p-values. You can see in that code that degrees of freedom are calculated and an object called se.diff, thus, you should be able to return them, too, by modifying the code.

使用我链接的帖子中修改后的paired.t.test,我添加了一点返回total.degf.如果你愿意,我会把它留给你来包含 se.dif.请注意,此代码仅用于示例目的,需要进行一些清理(例如,代码将 t.val 值识别为 p 值.这并不难更改.

Using the modified paired.t.test from the post I linked, I added a little bit to return total.degf. I'll leave it to you to include se.dif, if you want. Note that this code is for example purposes and needs some cleaning (e.g. the code recognizes the t.val values as being p-values. This wouldn't be hard to change.

my.pairded.t.test <- function (x, g, p.adjust.method = 
p.adjust.methods, pool.sd = TRUE,
...)
{
DNAME <- paste(deparse(substitute(x)), "and", 
deparse(substitute(g)))
g <- factor(g)
p.adjust.method <- match.arg(p.adjust.method)
if (pool.sd) {
    METHOD <- "t tests with pooled SD"
    xbar <- tapply(x, g, mean, na.rm = TRUE)
    s <- tapply(x, g, sd, na.rm = TRUE)
    n <- tapply(!is.na(x), g, sum)
    degf <- n - 1
    total.degf <- sum(degf)
    pooled.sd <- sqrt(sum(s^2 * degf)/total.degf)
    compare.levels <- function(i, j) {
        dif <- xbar[i] - xbar[j]
        se.dif <- pooled.sd * sqrt(1/n[i] + 1/n[j])
        t.val <- dif/se.dif
        #  2 * pt(-abs(t.val), total.degf)  this is commented out
        t.val    # this is added
    }
}
else {
    METHOD <- "t tests with non-pooled SD"
    compare.levels <- function(i, j) {
        xi <- x[as.integer(g) == i]
        xj <- x[as.integer(g) == j]
        t.test(xi, xj, ...)$statistic       # this is changed in case 
                            # pool.sd=F
    }
}
PVAL <- pairwise.table(compare.levels, levels(g), 
p.adjust.method)
ans <- list(method = METHOD, data.name = DNAME, p.value 
= PVAL,
    p.adjust.method = p.adjust.method, total.degf=total.degf) # I added the total.degf part
class(ans) <- "pairwise.htest"
ans
}

投入使用.

a<-my.pairded.t.test(Ozone, Month)
a$total.degf

这篇关于R中的ezANOVA和pairwise.t.test:输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆