简体   繁体   English

如何将aov()重新制作为汽车包装Anova(),以获得Mauchly对球形度,Greenhouse-Geisser和eta平方的检验?

[英]How to remake aov() to car package Anova() to get Mauchly's test for sphericity, Greenhouse-Geisser and eta-squared?

I want to convert a code written for aov() to Anova() function in car-package. 我想将为aov()编写的代码转换为car-package中的Anova()函数。

anovadata3 <- within(anovadata3, {
  subject <- factor(subject)
  time <- factor(time)
  gender <- factor(gender)
  group <- factor(group)
  groupgender <- factor(groupgender)
})

anovadata3.aov <- aov(values ~ time*group*gender + Error(subject),
                      data = anovadata3)
summary(anovadata3.aov)

This code give the me the following output: 这段代码为我提供了以下输出:

Error: subject
              Df Sum Sq Mean Sq F value  Pr(>F)   
group          1  32220   32220   8.632 0.00365 **
gender         1     30      30   0.008 0.92819   
group:gender   1     15      15   0.004 0.94952   
Residuals    221 824913    3733                   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Error: Within
                   Df Sum Sq Mean Sq F value   Pr(>F)    
time                3  21160    7053   9.223 5.53e-06 ***
time:group          3  18338    6113   7.993 3.06e-05 ***
time:gender         3   1916     639   0.835  0.47486    
time:group:gender   3  11679    3893   5.091  0.00172 ** 
Residuals         663 507012     765                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

However when i try using the Anova() function from car-package i do: 但是,当我尝试从汽车包装中使用Anova()函数时,我会这样做:

library(car)
mlm <- lm(values ~ time*group*gender, data = anovadata3)
rfactor <- factor(c("time", "gender","group","groupgender","subject"))
anovadata3.aov <- Anova(mlm, idata = dataframe(rfactor), idesign = ~ rfactor, type ="III")
summary(anovadata3.aov)

Which gives me this output. 这给了我这个输出。

     Sum Sq                Df         F value              Pr(>F)       
 Min.   :     58.3   Min.   :  1   Min.   :  0.03871   Min.   :0.00000  
 1st Qu.:   1324.9   1st Qu.:  1   1st Qu.:  0.54230   1st Qu.:0.04997  
 Median :  10281.5   Median :  3   Median :  1.57697   Median :0.21357  
 Mean   : 196286.3   Mean   :100   Mean   : 34.03103   Mean   :0.31053  
 3rd Qu.:  12290.4   3rd Qu.:  3   3rd Qu.:  2.61758   3rd Qu.:0.50989  
 Max.   :1331924.5   Max.   :884   Max.   :262.67095   Max.   :0.84408  
                                   NA's   :1           NA's   :1  

Does anyone know how i can remake the code that i use for aov() to fit the Anova(). 有谁知道我如何重新制作用于aov()的代码以适合Anova()。 I tried to follow the tutorial from: https://gribblelab.wordpress.com/2009/03/09/repeated-measures-anova-using-r/ 我试图从以下网站开始遵循本教程: https//gribblelab.wordpress.com/2009/03/09/repeated-measures-anova-using-r/

to try to get the Anova() correct. 尝试使Anova()正确。 But it doesn't give an output that looks similar. 但是它不会提供看起来相似的输出。 I also see from the webpage that it's suppose so give Mauchlys and Greenhouse, which i don't get. 我也从网页上看到它是应该的,所以给我不知道的Mauchlys和Greenhouse。 Also does anyone know how to get the eta-squared in the anova results? 还有人知道如何在方差分析结果中得到平方平方吗? Or is it necessary to use seperate function to calculate the eta (etaSquared()). 还是有必要使用单独的函数来计算eta(etaSquared())。

The data below was used for the test, and i'm trying to test if there is a significant difference in "values" between time, gender and group and interaction effects between the factors. 下面的数据用于测试,我正在尝试测试时间,性别和群体以及因素之间的交互作用之间的“值”是否存在显着差异。

          values  testperiod subject gender group groupgender time
1   118.82660110     Pretest       1      2     2   BSTfemale    1
2    61.07615138     Pretest       2      2     2   BSTfemale    1
3    57.51022740     Pretest       3      2     2   BSTfemale    1
4    70.73637347     Pretest       4      2     2   BSTfemale    1
5     9.86907880     Pretest       5      2     2   BSTfemale    1
6    64.51579546     Pretest       6      2     2   BSTfemale    1
7    63.25669342     Pretest       7      2     2   BSTfemale    1
8   109.09354856     Pretest       8      2     2   BSTfemale    1
9   140.69340502     Pretest       9      2     2   BSTfemale    1
10   93.94269807     Pretest      10      2     2   BSTfemale    1
11   43.76802256     Pretest      11      2     2   BSTfemale    1

...
898  60.85271722 FU_12_month     223      1     2     BSTmale    4
899  82.75598576 FU_12_month     224      1     2     BSTmale    4
900 -32.38497309 FU_12_month     225      1     2     BSTmale    4

The question seems a bit vague as to what is desired, but it's certainly not the first time someone has had difficulty getting what they wanted out of R's multivariate functions. 关于所需的条件,这个问题似乎有点含糊,但这当然不是第一次有人很难从R的多​​元函数中获得所需的信息。 I'm hoping that the term eta-squared is satisfied by the section on "Multivariate Tests:" in the result from summary.Anova.mlm with multivariate=TRUE which returns Pillai, Wilks, Hotelling-Lawley, and Roy tests and then separate sections (regardless of the value of multivariate parameter) for "Mauchly Tests for Sphericity" and "Greenhouse-Geisser and Huynh-Feldt Corrections for Departure from Sphericity". 我希望summary.Anova.mlm中的结果中“多元测试:”部分满足术语eta-squared的要求summary.Anova.mlm具有multivariate=TRUE ,它返回Pillai,Wilks,Hotelling-Lawley和Roy测试,然后将它们分开部分(与multivariate参数的值无关)的“球形性的极大检验”和“偏离球形性的Greenhouse-Geisser和Huynh-Feldt校正”。 I cannot tell if you just want the result scraped from a console session or if you wanted to do further processing with the results. 我不能告诉您是只希望从控制台会话中删除结果还是要对结果进行进一步处理。 (And that latter hope has occasioned more than one request on Rhelp in the past.) (过去那种希望在过去曾引起Rhelp多个请求。)

The code on the help page for car::Anova can be used to build an example for further discussion if needed (since you did not include a data example that could be copied): car :: Anova帮助页面上的代码可用于构建示例,以便在需要时进行进一步的讨论(因为您没有提供可以复制的数据示例):

phase <- factor(rep(c("pretest", "posttest", "followup"), c(5, 5, 5)),
    levels=c("pretest", "posttest", "followup"))
hour <- ordered(rep(1:5, 3))
idata <- data.frame(phase, hour)
idata
mod.ok <- lm(cbind(pre.1, pre.2, pre.3, pre.4, pre.5, 
                     post.1, post.2, post.3, post.4, post.5, 
                     fup.1, fup.2, fup.3, fup.4, fup.5) ~  treatment*gender, 
                data=OBrienKaiser)
class(AnoOBK <- Anova(mod.ok, idata= idata, idesign= ~phase*hour, type="III") # "Anova.mlm"

summary(AnoOBK)

> names(summary(AnoOBK))
[1] "type"               "repeated"           "multivariate.tests"
[4] "univariate.tests"   "pval.adjustments"   "sphericity.tests"  
[7] "SSPE"  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 R-部分eta平方重复测量ANOVA(汽车包装) - R- Partial eta squared for repeated measures ANOVA (car package) R 中的 Eta/Eta 平方例程 - Eta/Eta-squared routines in R 方差分析 LMER Eta 平方 - ANOVA LMER Eta squared 尽管设置 effect.size = 'ges',rstatix package anova_test function 给出了部分 eta 平方 - rstatix package anova_test function gives partial eta squared despite setting effect.size = 'ges' 如何使用重复测量计算秩对齐方差分析的部分 eta 平方(R 中的 ARTool package)? - How can I calculate partial eta squared for rank-aligned ANOVA with repeated measures (ARTool package in R)? 超出其90%置信区间的eta平方? - eta-squared outside its 90% confidence intervals? 在汽车包装的重复测量方差分析中调整球度校正的自由度 - Adjust degrees of freedom for sphericity correction in repeated measure Anova from car package 如何使用 Anova 命令进行 Tukey HSD 测试(汽车包) - How to do a Tukey HSD test with the Anova command (car package) 尝试获取重复测量方差分析的 AOV 结果时出错 - An error while trying to get AOV results of repeated measures ANOVA R: 对由 caret 包构建的逻辑模型进行 car::Anova type II 和 III 测试 - R: perform car::Anova type II and III test on logistic model built by caret package
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM