bluefoxr / COINr

COINr
https://bluefoxr.github.io/COINr/
Other
25 stars 8 forks source link

Leave one out plot #59

Closed coppertank closed 5 months ago

coppertank commented 5 months ago

First of all, I would like to compliment on the package and the clarity of the vignettes, highly appreciated.

I apologize in advance for the request if it doesn't comply with the idea of ​​the package, but I'll try anyway: I think it would be nice being able to specify in the plot_scatter function to plot all the indicators within a sub-pillar (or all the sub-pillars within a pillar) minus one.

This idea comes from reading the paper from Schlossarek et al. The Importance of Variables in Composite Indices: A Contribution to the Methodology and Application to Development Indices.

According to this paper, an indicator whose drop would cause the highest loss of the information provided by the index is the most important. In the appendix, in fact, there are the comparison of the information loss captured by plotting the whole index (or pillar, or sub-pillar) on one axis and the same index minus one of its components at a time, for all the components.

I think it would be a great implementation to reduce the number of indicators

bluefoxr commented 5 months ago

Hi @coppertank I'm not sure if I fully understood you, but is this something similar to the Removing elements functionality?

coppertank commented 5 months ago

Exactly! Just to be clear, the following image taken from the paper shows the Quality of Life component without one of its component at a time: Screenshot 2024-06-11 172128

Is there a way to achieve the same result graphically with the use of the function plot_scatter?

Thanks in advance

bluefoxr commented 5 months ago

No this can't be done directly with plot_scatter(), but what you could do is run the remove_elements() function and store the results as a list. Then have a look at the .$Scores table within that output list: this gives the scores resulting from the index with each element removed one at a time. It should only take a little wrangling to feed that into ggplot2 to get the plots above using e.g. faceting.

coppertank commented 5 months ago

I will try, thanks for the answer!

bluefoxr commented 5 months ago

Just to follow up before I close this issue: plot_scatter() is simply a quick wrapper around ggplot() which is meant for comparing one indicator against another. The same can be achieved also by extracting the data and using ggplot directly, but COINr provides a few quick plots here and there for either very common use cases, or else in cases where the plot is common but more complex (e.g. the plot_framework() plots). In your case I can see the usefulness of the plot but it is reasonably straightforward to do without building a new COINr function, so it doesn't seem like something that should be integrated into the package.

In any case hope the pointers were helpful and good luck with the plotting!

coppertank commented 5 months ago

As you suggested yesterday, I was able to store the results from removing one component at a time from the .$Scores table, store them in a dataset with the unaltered supbillar and plot the results. Thanks again for your availability!