bluefoxr / COINr

COINr
https://bluefoxr.github.io/COINr/
Other
22 stars 7 forks source link

SA and UA failure #50

Closed MoujibChahid closed 9 months ago

MoujibChahid commented 10 months ago

Hi Mr. Becker,

I'm entering the final step in the construction of my composite indicator, after several months of hard work. This involves carrying out an uncertainty and sensitivity analysis, following the OECD and JRC methodological guide, as well as your very rich and relevant documentation. However, after several attempts, these two important tests failed to run on COINr. I followed your documentation "literally" and used the same codes as you, but to no avail.

Here is the code used to set SA_specs (I have restricted the analysis to three assumptions) :

library(readxl) iData <- read_excel("/Users/moujib0/Desktop/SA_UA/SA_UA.xlsx", sheet = "iData") iMeta <- read_excel("/Users/moujib0/Desktop/SA_UA/SA_UA.xlsx", sheet = "iMeta")

library(COINr) coin <- new_coin(iData = iData, iMeta = iMeta) iData checked and OK. iMeta checked and OK. Written data set to .$Data$Raw coin <- qNormalise(coin, dset = "Raw", f_n = "n_minmax",

  • f_n_para = list(l_u = c(1, 100))) Written data set to .$Data$Normalised coin <- Aggregate(coin, dset = "Normalised", f_ag = "a_gmean") Written data set to .$Data$Aggregated norm_alts <- list(
  • list(f_n = "n_minmax", f_n_para = list(c(1,100))),
  • list(f_n = "n_zscore", f_n_para = list(c(10,2)))
  • ) l_norm <- list(Address = "$Log$Normalise$global_specs",
  • Distribution = norm_alts,
  • Type = "discrete") w_nom <- coin$Meta$Weights$Original noise_specs = data.frame(Level = c(1,2),
  • NoiseFactor = c(0.25, 0.25)) noisy_wts <- get_noisy_weights(w = w_nom, noise_specs = noise_specs, Nrep = 100) tail(noisy_wts[[1]]) iCode Level Weight 56 Economique 2 0.1818797 57 Communautaire 2 0.2222278 58 Infrastructure 2 0.1482263 59 Environnementale 2 0.2274701 60 Institutionnelle 2 0.1032904 61 Index 3 1.0000000 l_weights <- list(Address = "$Log$Aggregate$w",
  • Distribution = noisy_wts,
  • Type = "discrete") l_agg <- list(Address = "$Log$Aggregate$f_ag",
  • Distribution = c("a_amean", "a_gmean"),
  • Type = "discrete") SA_specs <- list(
  • Normalisation = l_norm,
  • Weights = l_weights,
  • Aggregation = l_agg
  • )

As you can see, the "corner" is built correctly and the weights created by the noise are displayed correctly too. Then I run this code and I validate address messages as specified in your documentation because I only use global_specs : SA_res <- get_sensitivity(coin, SA_specs = SA_specs, N = 100, SA_type = "UA", dset = "Aggregated", iCode = "Index")

Immediately afterwards, several error messages start to appear, knowing that calculations are still continuing. Among the messages obtained : Rep 1 of 100 ... 1% complete Regen failed. Probably a conflict between methods.

Rep 100 of 100 ... 100% complete Regen failed. Probably a conflict between methods.

Time elapsed = 12.88s, average 0.13s/rep.

Even when the calculations have been completed, no results are displayed and all fields are empty. When I run plot_uncertainty(SA_res) or plot_sensitivity(SA_res), the graphics are completely empty (see attachments).

Capture d’écran 2023-08-23 à 10 39 58 Capture d’écran 2023-08-23 à 10 41 14

I think it's just a coding problem to visualize the results with the plot_() function because when I run the get_sensitivity() function directly, all the results are displayed correctly but I can't visualize them graphically (see example below).

Could you remedy this display problem so that I can benefit from these very important results?

Thank you in advance for helping me overcome this LAST difficulty.

$Para$Aggregation [1] "a_gmean" "a_gmean" "a_gmean" "a_amean" "a_gmean" "a_gmean" "a_amean" "a_amean" "a_amean" "a_gmean" "a_gmean" [12] "a_gmean" "a_amean" "a_amean" "a_amean" "a_amean" "a_amean" "a_gmean" "a_gmean" "a_gmean" "a_amean" "a_gmean" [23] "a_gmean" "a_gmean" "a_amean" "a_gmean" "a_gmean" "a_gmean" "a_amean" "a_amean" "a_amean" "a_amean" "a_amean" [34] "a_amean" "a_gmean" "a_amean" "a_gmean" "a_gmean" "a_amean" "a_gmean" "a_amean" "a_gmean" "a_gmean" "a_amean" [45] "a_amean" "a_amean" "a_amean" "a_gmean" "a_gmean" "a_gmean" "a_amean" "a_gmean" "a_amean" "a_gmean" "a_gmean" [56] "a_gmean" "a_amean" "a_gmean" "a_gmean" "a_gmean" "a_gmean" "a_gmean" "a_gmean" "a_gmean" "a_gmean" "a_amean" [67] "a_amean" "a_amean" "a_gmean" "a_amean" "a_amean" "a_amean" "a_gmean" "a_gmean" "a_gmean" "a_amean" "a_gmean" [78] "a_amean" "a_amean" "a_gmean" "a_gmean" "a_gmean" "a_amean" "a_amean" "a_amean" "a_gmean" "a_gmean" "a_gmean" [89] "a_gmean" "a_gmean" "a_gmean" "a_amean" "a_amean" "a_gmean" "a_gmean" "a_gmean" "a_gmean" "a_gmean" "a_gmean" [100] "a_amean"

$Nominal uCode Score Rank 1 CYP 43.970603 5 2 DZA 8.647698 10 3 EGY 9.701159 9 4 ESP 53.199804 3 5 FRA 77.486926 1 6 GRC 45.263828 4 7 ITA 66.540628 2 8 MAR 19.881592 8 9 TUN 22.408466 7 10 TUR 28.659578 6

MoujibChahid commented 10 months ago

I'd like to point out that all the fields relating to the results of sensitivity and uncertainty analyses are empty (see example below), since they've already been calculated by COINr. I think this is the crux of the problem, and precisely the reason why the graphs are empty.

N.B.: I even activated the "ggplot2" library in case it could help me solve the problem, but it didn't work.

$Sensitivity Variable Si STi Si_q5 Si_q95 STi_q5 STi_q95 1 Normalisation NA NaN NA NA NA NA 2 Weights NA NaN NA NA NA NA 3 Aggregation NA NaN NA NA NA NA

MoujibChahid commented 10 months ago

I managed to fill in the "right" addresses for the various assumptions. Now, all calculations run without error and/or confirmation messages indicating a "NULL" address. However, some results are still empty, which prevents me from performing this analysis. Note that all plot_() graphs are completely empty. Only the plot_uncertainty(SA_res) graph contains a scatter plot that doesn't follow the country ranking, but just a straight line according to the equation y=x. Can you remedy this problem?

$Sensitivity Variable Si STi Si_q5 Si_q95 STi_q5 STi_q95 1 Winmax NaN NaN NA NA NA NA 2 Normalisation NaN NaN NA NA NA NA 3 Aggregation NaN NaN NA NA NA NA

$Nominal uCode Score Rank 1 CYP 44.748819 5 2 DZA 8.647698 10 3 EGY 9.738348 9 4 ESP 53.199804 3 5 FRA 77.565345 1 6 GRC 45.540569 4 7 ITA 66.731987 2 8 MAR 22.006930 8 9 TUN 23.051055 7 10 TUR 28.695319 6

Capture d’écran 2023-08-23 à 17 39 15
bluefoxr commented 10 months ago

Hi, if you are still having a problem with this please give me the means to reproduce the problem: the coin object plus the command you are running and the sensitivity specifications.

MoujibChahid commented 9 months ago

Hi, I returned to the old version of COINr6 and was able to carry out my calculations and obtain my graphs without any problem, using the same data.