bluefoxr / COINr6

Composite Indicator Construction and Analysis
Other
1 stars 1 forks source link

Imputation using imtype = "EM" and EMaglev = 1 returning "Error in .subset2(x, i, exact = exact) : attempt to select less than one element in get1index <real>" #2

Closed Petrina95 closed 1 year ago

Petrina95 commented 1 year ago

Hello again! I am trying to impute the missing data of my data set using EM aggregation type on aggregation level 1. However, there is an error that I think comes from the fact that we try to select an element from a list using agg_cols[[0]] syntax (line 279 in coin_impute.R). Is there a quick fix for this issue? I understand that COINr is a more updated package and today I have tried to convert our COINr6 script to a corresponding script using COINr, however I have noticed that many of the functionalities we are currently using in COINr6 are missing from COINr (imputation using regression, mixed aggregation per level, Unit reports etc.), that is why for now we prefer using COINr6.

Thank you in advance, Petrina

bluefoxr commented 1 year ago

HI, the EM algorithm has a limitation that you need a certain ratio of observations to variables to perform the imputation. That's why in COINr6 the imputation is performed within groups, rather than across the whole indicator set at once. So the fact that you can't choose level 1 is by design (though the error message is admittedly not helpful).

You could actually do what you want in COINr but it's up to you how to tackle it. For example, you can use the Impute() function to call the AMELIA package. Although it's not quite as easy as in COINr6, you have much more flexibility in specifying the imputation, so you can use the full power of the AMELIA package, rather than a very limited set of options in COINr6. Mixed aggregation methods by level is available in COINr. Unit reports are actually not very hard to generate - if you look at the code for unit report generation it's really simple. Then check the template used in COINr6 to see how it's set up.

The reason unit reports were removed is that you would anyway have to customise it to your needs, and I wanted to focus on doing the core job (building and analysing composite indicators) well, rather than trying to do everything. In any case they are still accessible if you are using COINr, you just convert your "coin" to a "COIN" and load COINr6.

Petrina95 commented 1 year ago

Thank you very much for your really informative answer!

I will check again COINr and hopefully I will manage to implement everything I need.

Best regards, Petrina