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

Plotting contrasts for categorical model with interaction #267

Open
Tracked by #289
a-difabio opened this issue Oct 28, 2024 · 0 comments
Open
Tracked by #289

Plotting contrasts for categorical model with interaction #267

a-difabio opened this issue Oct 28, 2024 · 0 comments
Labels
Plot 🎇 Something related to plotting
Milestone

Comments

@a-difabio
Copy link

When plotting contrasts for a model with an interaction term between two categorical variables, is it possible to split the lighthouse plots into facets?

It seems to me that the contrast are correctly calculated, but the output plot is not what I would expect.

library(ggplot2)
library(modelbased)
library(see)
data("Arabidopsis", package = "lme4")

model = lm(total.fruits ~ amd*status, Arabidopsis)
means = estimate_means(model)
#> We selected `by = c("amd", "status")`.
contrasts = estimate_contrasts(model, contrast = "amd", by = "status")
contrasts
#> Marginal Contrasts Analysis
#> 
#> Level1  |    Level2 |      status | Difference |          95% CI |   SE | t(619) |     p
#> ----------------------------------------------------------------------------------------
#> clipped | unclipped |      Normal |      -5.73 | [-14.02,  2.56] | 4.22 |  -1.36 | 0.175
#> clipped | unclipped | Petri.Plate |      -4.62 | [-21.61, 12.38] | 8.65 |  -0.53 | 0.594
#> clipped | unclipped |  Transplant |       0.37 | [-12.48, 13.21] | 6.54 |   0.06 | 0.955
#> 
#> Marginal contrasts estimated at amd
#> p-value adjustment method: Holm (1979)

plot(contrasts, means) +
    facet_wrap(vars(status))

Created on 2024-10-28 with reprex v2.1.0

@strengejacke strengejacke added the Plot 🎇 Something related to plotting label Dec 16, 2024
@strengejacke strengejacke added this to the 1.0.0 milestone Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Plot 🎇 Something related to plotting
Projects
None yet
Development

No branches or pull requests

2 participants