Open tomwenseleers opened 1 year ago
This is definitely something I want to implement - I would have to see how to consistently do this across model types.
Thanks for the suggestion.
This will require a re-write of a lot of code. Essentially we would need to have (internally) two types of processing functions:
For each model class, the "type" argument would have to be checked against what is possible for that model, and which packages are available. For example:
aov
, type 1 is default, while types 2/3 require car::Anova
aovlist
only type 1 is supportedmerMod
models, type 1 is from lme4:::anova.merMod
while types 2/3 are from lmerTest:::anova.merModLmerTest
merModLmerTest
models, type 1 is not possible)@strengejacke I know some of this is available in parameters
- do you know what might be missing to that effectsize
can completely rely on it?
You mean in terms of detecting the type?
I think the type detection is fully implemented in parameters for ANOVA tables.
For aov
/ maov
, what type is returned by parameters by default? Can I request all types?
For Anova.mlm
what is the default - univariate of multivariate tests?
If it would be too much hassle to rework large parts of the function, maybe just a little note in the help could be good saying that if you would like effect sizes for Anova tables (of whatever fit supported by https://rdrr.io/cran/car/man/Anova.html, i.e. lm, glm, multinom, polr, coxph, coxme, svyglm, svycoxph, rlm, lmer or lme), effectsize::eta_squared(car::Anova(fit, type=3)) is probably what you want (provided you used sum/effect coding using afex::set_sum_contrasts() and that all continuous covariates were centered first using scale())?
Well, we already have that:
car::Anova
.car::Anova
or afex
Thanks - I only just noticed those bits now. I guess it comes down to it being a bit unfortunate that the R folks only implemented type I SSs in their default anova() method, which you then use for most models "For all other model, effect sizes are approximated via test statistic conversion of the omnibus F statistic provided by the appropriate anova() method". Whereas it's Anova(type="III") results one would typically like to see for any model. But as long as this caveat is pointed out somewhere & how the proper effect sizes using type III SSs can be obtained I'm fine with that... I just thought an extra argument type=1, 2 or 3 could make this a bit more explicit... (As this is also the way this is done in some other effect size packages)
Describe the solution you'd like The current
eta_squared
function appears to return partial eta squared values based on type I SS. It is generally reckoned those are not very useful for factorial designs or models with interaction effects. It also leads to confusion, as the partial eta squared values of different packages have different defaults & options in this respect, sometimes using type I SS and sometimes type II or III, https://stats.stackexchange.com/questions/552451/which-r-functions-are-correct-for-estimating-partial-eta-squared-for-effects-in. At the very least an extra argumenttype=XX
would seem to be in order, as in theDescTools::EtaSq
function.How could we do it? To get partial eta squared values using type I, II or III SS I figured that with the
effectsize::eta_squared
function one would have to doeffectsize::eta_squared(fit)
or equivalentlyeffectsize::eta_squared(anova(fit)) # using type I tests
effectsize::eta_squared(car::Anova(fit, type=2)) # using type II tests
effectsize::eta_squared(car::Anova(fit, type=3)) # using type III tests, requires using effect coding / sum contrasts, cf afex::set_sum_contrasts() and all continuous covariates need to be centered using scale()
It would be nice if these could be obtained using
effectsize::eta_squared(fit, type=1, 2 or 3)