easystats/parameters

Issues with `parameters()` on `marginaleffects` objects

snhansen opened this issue · 2 comments

Consider this simple example:

library(marginaleffects)
library(parameters)
lm(mpg ~ wt, data = mtcars) |>
  hypotheses(hypothesis = "wt/100 = 0") |>
  parameters(digits = 5, exponentiate = TRUE)

Two things to consider:

  • The digits = 5 option works for all columns except for the confidence interval. I guess that's not intentional.
  • The exponentiate = TRUE option is completely ignored. Would be nice to have this option work for marginaleffects objects.

It seems like it is intentional that digits does not control CIs - which has a separate argument of ci_digits:

library(parameters)

m <- lm(mpg ~ am + hp, mtcars)
model_parameters(m, digits = 4, ci_digits = 9)
#> Parameter   | Coefficient |     SE |                       95% CI |   t(29) |      p
#> ------------------------------------------------------------------------------------
#> (Intercept) |     26.5849 | 1.4251 | [23.670268660, 29.499558836] | 18.6548 | < .001
#> am          |      5.2771 | 1.0795 | [ 3.069176923,  7.484993694] |  4.8883 | < .001
#> hp          |     -0.0589 | 0.0079 | [-0.074956650, -0.042818957] | -7.4952 | < .001
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed using a Wald t-distribution approximation.

I suggest keeping the option to set CIs digits separetly, but have them default to whatever digits is:

# Current
print.parameters_model <- function(x,
                                   digits = 2,
                                   ci_digits = 2,
                                   ...) {
  ...
}


# Suggested
print.parameters_model <- function(x,
                                   digits = 2,
                                   ci_digits = digits, # <<<<<<<<<<<<<<<<
                                   ...) {
  ...
}

Ah, I wasn't aware of the ci_digits argument. Thanks for the heads up. And yes, having that one default to digits when not specified seems like the right thing to do. I can't think of any situations where one doesn't want the same precision on the estimate and confidence interval.