Closed banfai closed 2 months ago
If the exclude argument of an emmc function is passed to emmeans (via ...), then it clashes with the exclude argument of .update.options():
exclude
emmc
emmeans
...
.update.options()
library(emmeans) emmeans(lm(Petal.Length ~ Species, data = iris), pairwise ~ Species, exclude = "setosa") #> Error in .update.options(result, options, ..., exclude = "adjust"): formal argument "exclude" matched by multiple actual arguments
Expected behavior can be achieved by passing a shortened form (e.g. exclud), but this reduces readability:
exclud
emmeans(lm(Petal.Length ~ Species, data = iris), pairwise ~ Species, exclud = "setosa") #> $emmeans #> Species emmean SE df lower.CL upper.CL #> setosa 1.46 0.0609 147 1.34 1.58 #> versicolor 4.26 0.0609 147 4.14 4.38 #> virginica 5.55 0.0609 147 5.43 5.67 #> #> Confidence level used: 0.95 #> #> $contrasts #> contrast estimate SE df t.ratio p.value #> versicolor - virginica -1.29 0.0861 147 -15.012 <.0001
It also doesn't work passing it in options:
options
emmeans(lm(Petal.Length ~ Species, data = iris), pairwise ~ Species, options = list(exclude = "setosa")) #> Argument 'exclude' was ignored. Valid choices are: #> adjust, alpha, avgd.over, bias.adjust, by.vars, calc, cross.adjust, delta, df, initMesg, estName, estType, famSize, frequentist, infer, inv.lbl, level, methDesc, nesting, null, predict.type, pri.vars, side, sigma, tran, tran.mult, tran.offset, tran2, type, is.new.rg, submodel, model.info, roles, grid, levels, matlevs, linfct, bhat, nbasis, V, dffun, dfargs, misc, post.beta #> $emmeans #> [...] #> #> $contrasts #> contrast estimate SE df t.ratio p.value #> setosa - versicolor -2.80 0.0861 147 -32.510 <.0001 #> setosa - virginica -4.09 0.0861 147 -47.521 <.0001 #> versicolor - virginica -1.29 0.0861 147 -15.012 <.0001 #> #> P value adjustment: tukey method for comparing a family of 3 estimates
I know that it is discouraged to use emmeans to obtain contrasts directly, and it indeed does work using it separately, but it seems to be easy to fix to work directly (see PR)
contrast(emmeans(lm(Petal.Length ~ Species, data = iris), ~ Species), method = "pairwise", exclude = "setosa") #> contrast estimate SE df t.ratio p.value #> versicolor - virginica -1.29 0.0861 147 -15.012 <.0001
PR has been merged.
If the
exclude
argument of anemmc
function is passed toemmeans
(via...
), then it clashes with theexclude
argument of.update.options()
:Expected behavior can be achieved by passing a shortened form (e.g.
exclud
), but this reduces readability:It also doesn't work passing it in
options
:I know that it is discouraged to use
emmeans
to obtain contrasts directly, and it indeed does work using it separately, but it seems to be easy to fix to work directly (see PR)