IndrajeetPatil / ggstatsplot

Enhancing {ggplot2} plots with statistical analysis 📊📣
https://indrajeetpatil.github.io/ggstatsplot/
GNU General Public License v3.0
1.99k stars 184 forks source link

Greenhouse-Geisser-corrected degrees of freedom for RM ANOVA #227

Closed IndrajeetPatil closed 5 years ago

IndrajeetPatil commented 5 years ago

I want the subtitle_anova_parametric function to by default return Greenhouse-Geisser-corrected dfs for RM ANOVA.

For example, here is output from JASP of what this looks like:

image

Currently, sphericity.correction = TRUE returns only corrected p-values:

# checking subtitle
ggstatsplot::subtitle_anova_parametric(
  data = ggstatsplot::iris_long,
  x = condition,
  y = value,
  paired = TRUE,
  sphericity.correction = TRUE,
  messages = FALSE
)

#> paste(NULL, italic("F"), "(", "3", ",", "447", ") = ", "776.32", 
#>     ", ", italic("p"), " = ", "< 0.001", ", ", omega^2, " = ", 
#>     "0.71", ", CI"["95%"], " [", "0.77", ", ", "0.82", "]", ", ", 
#>     italic("n"), " = ", 150L)

This is because I haven't been able to figure out where does ez store these corrected dfs, if it even does that:

# checking object from ez
ez_df <-
  ez::ezANOVA(
    data = ggstatsplot::iris_long,
    dv = value,
    wid = id,
    within = condition,
    detailed = TRUE,
    return_aov = TRUE
  )
#> Warning: Converting "id" to factor for ANOVA.

# checking all available options from ez object to obtain corrected dfs
ez_df$ANOVA
#>        Effect DFn DFd      SSn      SSd         F             p p<.05
#> 1 (Intercept)   1 149 7201.656 363.4814 2952.1371 4.066593e-100     *
#> 2   condition   3 447 1656.263 317.8893  776.3182 8.529938e-177     *
#>         ges
#> 1 0.9135648
#> 2 0.7085212

ez_df$`Mauchly's Test for Sphericity`
#>      Effect         W             p p<.05
#> 2 condition 0.0187656 1.358871e-124     *

ez_df$`Sphericity Corrections`
#>      Effect       GGe        p[GG] p[GG]<.05       HFe        p[HF]
#> 2 condition 0.3830366 1.324548e-69         * 0.3840953 8.669317e-70
#>   p[HF]<.05
#> 2         *

I guess the other option is to manually compute them using the correction (epsilon) value?

IndrajeetPatil commented 5 years ago

@ibecav Following up on #188, any thoughts on this? You had mentioned there that corrected dfs should be in the returned ez list, but I can't find it there.

ibecav commented 5 years ago

Yes please see reprex


# ugh iris_long
ez_df <-
  ez::ezANOVA(
    data = ggstatsplot::iris_long,
    dv = value,
    wid = id,
    within = condition,
    detailed = TRUE,
    return_aov = TRUE
  )
#> Warning: Converting "id" to factor for ANOVA.
# We take Greenhouse-Geisser epsilon and multiple by uncorrected df
# We get the same answer as JASP
# you can of course get the raw df from anywhere
ez_df$`Sphericity Corrections`$GGe * ez_df$ANOVA$DFn[2]
#> [1] 1.14911

Created on 2019-06-04 by the reprex package (v0.3.0)