Skip to content

Is it possible to do standard contrasts across an interaction with the default-backend? #510

@profandyfield

Description

@profandyfield

I'm trying to reproduce this analysis using modelbased::estimate_contrasts(). It's basically a set of 'out of the box' contrasts fitted across an interaction.

date_tib <- discovr::speed_date

date_afx <- afex::aov_4(date ~ strategy*looks*personality + (looks*personality|id), data = date_tib)
#> Contrasts set to contr.sum for the following variables: strategy

# Desired analysis using emmeans

three_way_emm <- emmeans::emmeans(date_afx, specs = c("strategy", "looks", "personality"), model = "multivariate")

emmeans::contrast(
  three_way_emm,
  interaction = c(strategy = "trt.vs.ctrl",
                  looks = "trt.vs.ctrl",
                  personality = "trt.vs.ctrl"),
  ref = 2,
  adjust = "holm"
  )
#>  strategy_trt.vs.ctrl looks_trt.vs.ctrl personality_trt.vs.ctrl estimate   SE
#>  Normal - Hard to get Low - Average     Low - Average               -4.7 4.07
#>  Normal - Hard to get High - Average    Low - Average              -36.2 4.65
#>  Normal - Hard to get Low - Average     High - Average              18.5 5.41
#>  Normal - Hard to get High - Average    High - Average              -5.8 6.02
#>  df t.ratio p.value
#>  18  -1.155  0.5263
#>  18  -7.789  <.0001
#>  18   3.421  0.0091
#>  18  -0.963  0.5263
#> 
#> P value adjustment: holm method for 4 tests

Created on 2025-06-11 with reprex v2.1.1

I can't see a way to set the contrasts across an interaction in estimate_contrasts() (without manually specifying weights but let's not go there ...). The function documentation doesn't mention an equivalent to interactiuon = that gets passed onto emmeans. But also, highly likley I just don't know how to use your function:) Is there a way? If not, is this something you'd impliment?

Incidentally, I'd prefer to do it without changing the backend to emmeans (because everything else in my book uses the default marginaleffects backend), but if it has to be changed then so be it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Enhancement 💥Implemented features can be improved or revisedFeature idea 🔥New feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions