Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anova - report sums of squares type + coding #159

Open
mattansb opened this issue Apr 15, 2021 · 16 comments
Open

Anova - report sums of squares type + coding #159

mattansb opened this issue Apr 15, 2021 · 16 comments
Assignees
Labels
enhancement 💥 Implemented features can be improved or revised

Comments

@mattansb
Copy link
Member

This matters a lot, and without this context there is no way to interpret the results.

@IndrajeetPatil IndrajeetPatil added the enhancement 💥 Implemented features can be improved or revised label Apr 16, 2021
@IndrajeetPatil
Copy link
Member

Can you please modify and repost the output below to match your expectations? Will give a better idea about how we can achieve this.

library(report)

mod <- aov(formula = Sepal.Length ~ Species, data = iris)

report(mod)
#> The ANOVA (formula: Sepal.Length ~ Species) suggests that:
#> 
#>   - The main effect of Species is statistically significant and large (F(2, 147) = 119.26, p < .001; Eta2 = 0.62, 90% CI [0.54, 0.68])
#> 
#> Effect sizes were labelled following Field's (2013) recommendations.

Created on 2021-04-16 by the reprex package (v2.0.0)

@mattansb
Copy link
Member Author

It should be in the first line, before the actual stats.

I assigned myself, I'll make the needed changes (and try to also add support for afex / anova objects at the same time).

@strengejacke
Copy link
Member

Fixed.

library(report)

mod <- aov(formula = Sepal.Length ~ Species, data = iris)

report(mod)
#> Don't use ANOVA. 

@bwiernik
Copy link
Contributor

Related to @strengejacke's point, I wonder whether it would be good to also report the actual regression coefficients in addition to/instead of eta2?

@mattansb
Copy link
Member Author

If anyone is using aov I'd say they're not interested in the coefs (and if they're using effects coding, they would have little information in them really...)

They can always report(lm(aovMod)) 🤷‍♂️

@mattansb
Copy link
Member Author

Okay, I've lost track of the API here.... @IndrajeetPatil Can you help me out?

This first sentence should be changed:

report(mod)
#> The {type} ANOVA (formula: Sepal.Length ~ Species) suggests that:

Looking at R/report.aov.R, I see serval methods:

  • aov - Type I tests (sequential)
  • aovlist - Type I tests (sequential)
  • anova - it depends... not all anova objects are the same. The printing method should tell you what type it is (if not, should default to Type I tests (sequential)). Can be:
    • Type II tests (marginal)
    • Type III tests (simultaneous)

This information seems to be stored in the "heading" attributes:

mod <- aov(Sepal.Length ~ Species * Sepal.Width, data = iris)
mod2 <- lmerTest::lmer(Sepal.Length ~ Sepal.Width + (1|Species), data = iris)


a0 <- anova(mod)
a1 <- car::Anova(mod, type = 2)
a2 <- car::Anova(mod, type = 3)
a3 <- anova(mod2)


attr(a0, "heading")
#> [1] "Analysis of Variance Table\n" "Response: Sepal.Length"
attr(a1, "heading")
#> [1] "Anova Table (Type II tests)\n" "Response: Sepal.Length"
attr(a2, "heading")
#> [1] "Anova Table (Type III tests)\n" "Response: Sepal.Length"
attr(a3, "heading")
#> [1] "Type III Analysis of Variance Table with Satterthwaite's method"

Created on 2021-04-18 by the reprex package (v1.0.0)

@mattansb
Copy link
Member Author

(people are gonna be doing type-1 tests with treatment-coding and think they're doing type-3 tests with effects-doing... daymn)

@bwiernik
Copy link
Contributor

I think that most folks using R for ANOVA (why?) are used to using car::Anova() or es::aov_ex() instead of base R aov(). This is an oddness of S/R's aov() and anova() functions that has lamented by various folks for 50 years.

@DominiqueMakowski
Copy link
Member

if anyone is using aov I'd say they're not interested in the coefs

I agree

I think that most folks using R for ANOVA (why?) are used to using car::Anova() or es::aov_ex() instead of base R aov()

I wouldn't be so sure, I've seen (too) many serious usage of aov() ^^ (maybe it's a psych thing 🤷)

@bwiernik
Copy link
Contributor

if anyone is using aov I'd say they're not interested in the coefs

Well, perhaps not, but I'd argue they should be. 😜

@mattansb
Copy link
Member Author

Well, perhaps not, but I'd argue they should be. 😜

Finally, a hill for me to die on!
(Seeing as how for proper SS in anova you should be using effects coding (or similar), coefs become virtually uninterpretable. The role of coef-inspection is replaced with simple-effects, expected means, and contrasts instead ^_^)

@mattansb
Copy link
Member Author

I wouldn't be so sure, I've seen (too) many serious usage of aov() ^^ (maybe it's a psych thing 🤷)

Yeah, this is very unfortunate 😔

@mattansb
Copy link
Member Author

I think perhaps this should be supported elsewhere:

  • parameters should have the "type" as a footer for the tests
  • effectsize should have the "type" as a footer for the effect size (can pull from parameters?)
    Then report can pull from those.

@strengejacke what do you think?

@IndrajeetPatil
Copy link
Member

Should the exact details of the type of test contained in title attribute of model_parameters output?

I think this is what we currently do:

mod <- stats::t.test(formula = wt ~ am, data = mtcars)

attributes(parameters::parameters(mod))$title
#> [1] "Welch Two Sample t-test"

Created on 2021-04-20 by the reprex package (v2.0.0)

@mattansb
Copy link
Member Author

Yes, just as this info appears in the title of anova objects:

anova(lmerTest::lmer(Reaction ~ Days + (Days | Subject), lme4::sleepstudy))
#> Type III Analysis of Variance Table with Satterthwaite's method
#>      Sum Sq Mean Sq NumDF DenDF F value    Pr(>F)    
#> Days  30031   30031     1    17  45.853 3.264e-06 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Created on 2021-04-20 by the reprex package (v1.0.0)

@mattansb
Copy link
Member Author

bump
This should probably be delt with before #342 - parameters and effectsize already return the type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 💥 Implemented features can be improved or revised
Projects
None yet
Development

No branches or pull requests

5 participants