-
-
Notifications
You must be signed in to change notification settings - Fork 23
Closed
Labels
Bug 🐛Something isn't workingSomething isn't working
Description
Is it possible to do pairwise comparisons of slopes in an ANCOVA?
Consider this model
library(palmerpenguins)
library(modelbased)
m <- lm(flipper_length_mm ~ body_mass_g * species, data = penguins)
I want to recreate the following, which is easy to do in emmeans:
library(emmeans)
emtrends(m, ~ species, var = "body_mass_g") %>%
pairs()
It gives
contrast estimate SE df t.ratio p.value
Adelie - Chinstrap -0.00529 0.00196 327 -2.704 0.0197
Adelie - Gentoo -0.00273 0.00138 327 -1.978 0.1192
Chinstrap - Gentoo 0.00256 0.00196 327 1.305 0.3933
Running what I thought was the equivalent in modelbased:
estimate_contrasts(
m,
contrast = "species",
trend = "body_mass_g",
p_adjust = "tukey"
)
Gives
Marginal Contrasts Analysis
Level1 | Level2 | Difference | SE | 95% CI | t(327) | p
----------------------------------------------------------------------------
Chinstrap | Adelie | 8.05 | 1.23 | [ 5.64, 10.46] | 6.57 | < .001
Gentoo | Adelie | 15.55 | 1.20 | [13.20, 17.90] | 13.01 | < .001
Gentoo | Chinstrap | 7.50 | 1.44 | [ 4.67, 10.33] | 5.21 | < .001
Variable predicted: flipper_length_mm
Predictors contrasted: species
Predictors averaged: body_mass_g (4.2e+03)
p-value adjustment method: Tukey
It seems to be comparisons for flipper_length_mm along the mean of body_mass_g.
Is there a way to do pairwise comparisons of slopes? I would like to use the modelbased package for an introductory stats class and I like its functions and output.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Bug 🐛Something isn't workingSomething isn't working