Closed consultfiv closed 1 month ago
Thanks for your suggestion. I went through and edited your comment. adding Markdown markup for code, so you can see the indentation and alignment. I also removed the "bug" tag, since this isn't a bug.
I guess this illustrates that different people have different preferences in how to present statistical results. But I personally do not regard this as an improvement at all. The fact that in the original contrast
output, some odds ratios are greater than 1 and others are less than 1 is important information that is immediately apparent, and I think reversing the direction of some ratios adds confusion.
In addition, the original output contains annotations that inform us about P-value adjustments, etc. that are not present in the tibble version. These annotations are important enough to me that I have a special startup message warning people not to suppress them (see ? untidy
). I also am not myself a fan of tibbles; yes, data frames are idiosyncratic, and tibbles "solve" some of them; but they do so by creating other idiosyncrasies and add advertising ("a tibble"), unneeded row numbers, and distracting information about storage types. If we are going to add extra lines to the output, I'd rather show information that is actually useful. I realize that is just my opinion.
There are other packages that re-package emmeans's output in various ways to suit the preferences of particular user communities. I do recognize that different users have different needs, but I think the invert_OR()
function would better be incorporated in a separate package, rather than in emmeans.
By the way, your specification pairwise ~ Feature1
is unneeded; you'll get the same results using ~ Feature1
while avoiding computing the pairwise comparisons twice.
Also, a simple way to obtain the same ordering without reversing any odds ratios is to sort by p.value
Thank you for your attention and for your responses. I understand all you said. Anyway, congrats for building such a great package which I have been enjoying and recommending since the day I discovered it.
I'm closing this issue, as it is resolved.
Describe the bug
This it is not a bug itself, it is just a recommendation for an improvement in the emmeans function, in order to make improved console's outputs. I tried and achieved to get an improve output in the console that I think it provides easier and faster interpretations of the results.
Expected behaviour
This R script (requires packages "emmeans" and "dplyr") creates a function that performs several key steps for analyzing and transforming the results of a generalized linear model (GLM) using the emmeans package. Here’s a breakdown of the process:
After the emmeans function calculates the estimated marginal means for the Feature1 levels, and pairwise comparisons between these levels are performed, the results are converted to a tibble and numeric values are rounded to three decimal places for clarity. For odds ratios less than 1, their inverse is calculated, along with inverses for the corresponding confidence intervals (LCL and UCL). The contrasts are also reversed. The dataframe is updated to include the transformed odds ratios and confidence intervals, and variables are renamed to reflect these changes. The dataframe is ordered by the odds ratio in descending order to highlight the most significant effects. This script ensures that the analysis correctly handles and interprets odds ratios and their confidence intervals, especially when dealing with ratios less than 1, and organizes the results for easy interpretation.
To reproduce
(To facilitate its use, I converted it directly to a function. I also deleted comments, if you want them I can also provide comments for each action)
example:
Show the actual output
Additional context
As you can see, with the functionality of invert_OR( ), which it would be desireble to be as an aditional option included in the original function, every relationship is given in odds ratio bigger than 1, facilitating the interpretation of the relationship between each term of each pair.
Emmeans regular output look like this: