easystats / report

:scroll: :tada: Automated reporting of objects in R
https://easystats.github.io/report/
Other
694 stars 70 forks source link

What is the expected behaviour for report(estimate_contrasts(model))? #399

Open alexisdmacintyre opened 12 months ago

alexisdmacintyre commented 12 months ago

Question and context Based on this documentation and discussion here, my understanding is that report() should return a little write-up summarising the results of an estimate_contrasts object. However, when I try this with my fitted lmer model, I just get generic descriptive statistics. The same thing happens for me if I run the example from the documentation:

library(modelbased)
model <- lm(Sepal.Width ~ Species, data = iris)
contr <- estimate_contrasts(model)
report(contr)

The expected response (according to the documentation):

#> The marginal contrasts analysis suggests the following. The difference between
#> setosa and versicolor is positive and statistically significant (difference =
#> 0.66, 95% CI [ 0.49, 0.82], t(147) = 9.69, p < .001). The difference between
#> setosa and virginica is positive and statistically significant (difference =
#> 0.45, 95% CI [ 0.29, 0.62], t(147) = 6.68, p < .001). The difference between
#> versicolor and virginica is negative and statistically significant (difference
#> = -0.20, 95% CI [-0.37, -0.04], t(147) = -3.00, p = 0.003)

What I get:

The data contains 3 observations of the following 9 variables:

  - Level1: 2 entries, such as setosa (n = 2); versicolor (n = 1); NA (0 missing)
  - Level2: 2 entries, such as virginica (n = 2); versicolor (n = 1); NA (0 missing)
  - Difference: n = 3, Mean = 0.30, SD = 0.45, Median = 0.45, MAD = 0.30, range: [-0.20, 0.66], Skewness = -1.34, Kurtosis = -1.50, 0 missing
  - CI_low: n = 3, Mean = 0.14, SD = 0.45, Median = 0.29, MAD = 0.30, range: [-0.37, 0.49], Skewness = -1.34, Kurtosis = -1.50, 0 missing
  - CI_high: n = 3, Mean = 0.47, SD = 0.45, Median = 0.62, MAD = 0.30, range: [-0.04, 0.82], Skewness = -1.34, Kurtosis = -1.50, 0 missing
  - SE: n = 3, Mean = 0.07, SD = 1.70e-17, Median = 0.07, MAD = 0.00, range: [0.07, 0.07], Skewness = 0.82, Kurtosis = -2.00, 0 missing
  - df: n = 3, Mean = 147.00, SD = 0.00, Median = 147.00, MAD = 0.00, range: [147, 147], Skewness = , Kurtosis = , 0 missing
  - t: n = 3, Mean = 4.46, SD = 6.63, Median = 6.68, MAD = 4.45, range: [-3.00, 9.69], Skewness = -1.34, Kurtosis = -1.50, 0 missing
  - p: n = 3, Mean = 1.05e-03, SD = 1.82e-03, Median = 9.08e-10, MAD = 1.35e-09, range: [5.50e-17, 3.15e-03], Skewness = 1.73, Kurtosis =
-1.50, 0 missing

I generated above using report 0.5.7 and modelbased 0.8.6 with R version 4.3.1 on Windows 10.

rempsyc commented 1 month ago

This is what I get with a reprex:

packageVersion("report")
#> [1] '0.5.9'
packageVersion("modelbased")
#> [1] '0.8.8'
library(modelbased)
library(report)
model <- lm(Sepal.Width ~ Species, data = iris)
contr <- estimate_contrasts(model)
#> No variable was specified for contrast estimation. Selecting `contrast =
#>   "
#>   Species
#>   "`.
report(contr)
#> The marginal contrasts analysis suggests the following. The difference between
#> setosa and versicolor is positive and statistically significant (difference =
#> 0.66, 95% CI [ 0.49, 0.82], t(147) = 9.69, p < .001). The difference between
#> setosa and virginica is positive and statistically significant (difference =
#> 0.45, 95% CI [ 0.29, 0.62], t(147) = 6.68, p < .001). The difference between
#> versicolor and virginica is negative and statistically significant (difference
#> = -0.20, 95% CI [-0.37, -0.04], t(147) = -3.00, p = 0.003)

Created on 2024-09-13 with reprex v2.1.1

Can you try updating report to the latest version? I just checked in the link to the other discussion you linked and support for estimate_contrast in report was only officially added from version 0.5.8, so the results you had was the previous behaviour before support was added.