Hello and thank you once again for taking the time to build this library!
I am in the process of developing this year's Index and I need to perform outlier treatment. I have been using the Coinr6:: treat() function with specifying individual treatment for some of the indicators.
The code is the following:
individual = data.frame(
IndCode = c("IND_1","IND_4","IND_6","IND_32","IND_15","IND_22","IND_27","IND_26","IND_28","IND_30","IND_36","IND_37"),
Treat = c("win", "win", "win", "win", "win", "win", "win", "win", "win", "win", "win", "win"),
Winmax = c(2,1,1,2,1,1,2,2,1,1,2,1),
Thresh = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
Boxlam = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)
)
coin<- treat(coin, dset = "Raw", individual = individual,
indiv_only = TRUE)
However there are two cases where the treatment does not work as expected.
- In the first case indicator 1 is flagged with 1 Low outlier and even if I have forced it to winsorise 2 points it winsorise only 1, as you can see in the picture.
I managed to find a workaround by setting the threshold for skew and kurtosis to t_skew=-0.2, t_kurt=-0.5 only for this indicator, so the code now is the following:
individual = data.frame(
IndCode = c("IND_1","IND_4","IND_6","IND_32","IND_15","IND_22","IND_27","IND_26","IND_28","IND_30","IND_36","IND_37"),
Treat = c("win", "win", "win", "win", "win", "win", "win", "win", "win", "win", "win", "win"),
Winmax = c(2,1,1,2,1,1,2,2,1,1,2,1),
# thres was added as a workaround to treat both points for indicator 1, otherwise it would treat only 1 point
Thresh = c("thresh", NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
Boxlam = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)
)
#coin<- treat(coin, dset = "Raw", individual = individual,
# indiv_only = TRUE)
coin<- treat(coin, dset = "Raw", individual = individual,
indiv_only = TRUE, t_skew=-0.2, t_kurt=-0.5)
- In the second case, indicator 36 is flagged with 3 outliers and since I have forced to treat 2 points it seems that the winsored points are 2.
However, when I look at coin$Analysis$Treated$TreatFlags
, there are three points that have been flagged and searching further into coin$Data$Treated
I confirm that 3 points have been treated and not 2.
Do you know what could be the issue?
When does an outlier is flagged in coin$Analysis$Treated$TreatFlags
if we specified not to check any thresholds setting Thresh
to NA?
Moreover, is there the possibility to pass two different thresholds for skew and kurtosis, to force in this way the treatment on the points I need to treat?
I know that COINr is a more updated package, however I have also tried using Treat() function with specifying individual treatment, and it does not seem to work as I have also uploaded at [bluefoxr/COINr/issues/53] .
Thank you in advance,
Petrina