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

correlation formatting doesn't apply digits to the CI formatting #337

Open
DominiqueMakowski opened this issue Jan 19, 2025 · 5 comments
Open

Comments

@DominiqueMakowski
Copy link
Member

Received by email:

However, I noticed that when one changes the number-of-digits display using the digits argument, that the display for the Pearson’s r value and for the associated t statistic are changed, but the confidence interval limits stay at 2-digits status regardless of the argument value.

CI stays with 2 digits (but it works in parameters)

correlation::correlation(iris, digits=1)
#> # Correlation Matrix (pearson-method)
#> 
#> Parameter1   |   Parameter2 |    r |         95% CI | t(148) |         p
#> ------------------------------------------------------------------------
#> Sepal.Length |  Sepal.Width | -0.1 | [-0.27,  0.04] |   -1.4 | 0.152    
#> Sepal.Length | Petal.Length |  0.9 | [ 0.83,  0.91] |   21.6 | < .001***
#> Sepal.Length |  Petal.Width |  0.8 | [ 0.76,  0.86] |   17.3 | < .001***
#> Sepal.Width  | Petal.Length | -0.4 | [-0.55, -0.29] |   -5.8 | < .001***
#> Sepal.Width  |  Petal.Width | -0.4 | [-0.50, -0.22] |   -4.8 | < .001***
#> Petal.Length |  Petal.Width |  1.0 | [ 0.95,  0.97] |   43.4 | < .001***
#> 
#> p-value adjustment method: Holm (1979)
#> Observations: 150

parameters::parameters(lm(Sepal.Length ~ Sepal.Width, data=iris), digits=1)
#> Parameter   | Coefficient |  SE |      95% CI | t(148) |      p
#> ---------------------------------------------------------------
#> (Intercept) |         6.5 | 0.5 | [ 5.6, 7.5] |   13.6 | < .001
#> Sepal Width |        -0.2 | 0.2 | [-0.5, 0.1] |   -1.4 | 0.152
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a Wald t-distribution approximation.

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

@strengejacke
Copy link
Member

correlation::correlation(iris, digits=1, ci_digits = 5)
#> # Correlation Matrix (pearson-method)
#> 
#> Parameter1   |   Parameter2 |    r |               95% CI | t(148) |         p
#> ------------------------------------------------------------------------------
#> Sepal.Length |  Sepal.Width | -0.1 | [-0.27269,  0.04351] |   -1.4 | 0.152    
#> Sepal.Length | Petal.Length |  0.9 | [ 0.82704,  0.90551] |   21.6 | < .001***
#> Sepal.Length |  Petal.Width |  0.8 | [ 0.75690,  0.86484] |   17.3 | < .001***
#> Sepal.Width  | Petal.Length | -0.4 | [-0.55088, -0.28795] |   -5.8 | < .001***
#> Sepal.Width  |  Petal.Width | -0.4 | [-0.49721, -0.21870] |   -4.8 | < .001***
#> Petal.Length |  Petal.Width |  1.0 | [ 0.94905,  0.97299] |   43.4 | < .001***
#> 
#> p-value adjustment method: Holm (1979)
#> Observations: 150

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

@DominiqueMakowski
Copy link
Member Author

what about the inconsistency with parameters() in which it gets changed by ci?

@DominiqueMakowski
Copy link
Member Author

I would still have by default ci_digits=digits, and only have them different if both are specified by the user

@strengejacke strengejacke reopened this Jan 19, 2025
@strengejacke
Copy link
Member

Ok, we just need to add it to the print and/or format methods, I guess?

@DominiqueMakowski
Copy link
Member Author

I think so probably here

format.easycorrelation <- function(x,
digits = NULL,
p_digits = NULL,
stars = NULL,
format = NULL,
...) {

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

No branches or pull requests

2 participants