Skip to content

[Consistency] estimate_slopes() #300

Merged
strengejacke merged 32 commits intomainfrom
homogenize_slopes
Jan 9, 2025
Merged

[Consistency] estimate_slopes() #300
strengejacke merged 32 commits intomainfrom
homogenize_slopes

Conversation

@DominiqueMakowski
Copy link
Member

@DominiqueMakowski DominiqueMakowski commented Jan 9, 2025

Fixes #298
Fixes #288
Fixes #225

We should try to match the emmeans' output I'd say, i.e., in marginaleffects:

  • Keep SE
  • Keep Statistic but rename it to the actual statistic name (if possible?)

@strengejacke
Copy link
Member

If you add

Fixes #298
Fixes #288

etc. in the beginning of the description, related issues will be closed automatically on merge.

@strengejacke
Copy link
Member

strengejacke commented Jan 9, 2025

For #301, I had to include the parameter column, which is now missing here after merging main into this PR:

trends <- datawizard::data_remove(trends, c("Statistic", "SE", "S", "CI", "df", "rowid_dedup"), verbose = FALSE) # nolint

You must check if everything is still ok in this PR, but for contrasts / contrasting slopes, we need the Parameter column, else the output makes no sense. However, sometimes that column is redundant, containing only "dx/dy". We need to check more in depth later and improve the handling.

@DominiqueMakowski
Copy link
Member Author

can we add that if unique(col) == "dx/dy" we drop it?

@strengejacke
Copy link
Member

If you add

Fixes #298
Fixes #288

etc. in the beginning of the description, related issues will be closed automatically on merge.

That's why I love the VSCode/Positron features for working with GitHub, so comfortable...

@strengejacke
Copy link
Member

can we add that if unique(col) == "dx/dy" we drop it?

Yes, maybe we add a small helper-functions that checks for all unneeded content. Not sure if "dx/dy" will be the only exception. But for now, just checking for that value should work.

@strengejacke
Copy link
Member

image

@strengejacke
Copy link
Member

For emmeans, using estimate_means() , we do not report df and statistic.

@strengejacke
Copy link
Member

data(mtcars)
data(iris)

dat <- mtcars
dat$gear <- as.factor(dat$gear)
dat$cyl <- as.factor(dat$cyl)
dat <<- dat

# Simple
model <- lm(vs ~ cyl, data = dat)
modelbased::estimate_means(model)
#> We selected `by = c("cyl")`.
#> Estimated Marginal Means
#> 
#> cyl |     Mean |   SE |        95% CI
#> -------------------------------------
#> 4   |     0.91 | 0.09 | [ 0.72, 1.09]
#> 6   |     0.57 | 0.11 | [ 0.34, 0.80]
#> 8   | 2.22e-16 | 0.08 | [-0.16, 0.16]
#> 
#> Marginal means estimated at cyl
modelbased::estimate_means(model, backend = "marginaleffects")
#> Estimated Marginal Means
#> 
#> cyl |     Mean |   SE |        95% CI |    t(29)
#> ------------------------------------------------
#> 4   |     0.91 | 0.09 | [ 0.72, 1.09] |    10.02
#> 6   |     0.57 | 0.11 | [ 0.34, 0.80] |     5.03
#> 8   | 2.22e-16 | 0.08 | [-0.16, 0.16] | 2.76e-15
#> 
#> Marginal means estimated at cyl

Created on 2025-01-09 with reprex v2.1.1

@strengejacke strengejacke merged commit 9e2e4ee into main Jan 9, 2025
17 of 22 checks passed
@strengejacke strengejacke deleted the homogenize_slopes branch January 9, 2025 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consistency in outputs for emmeans/marginaleffects wrapper Consistency for "categorical" family brms models Fix broken example

2 participants