I would like to use a distance correlation/covariance analysis to detect (non-linear) dependencies in my data in R. However, my data has a lot of NAs so, after filter them (because dcor/dcov implementation in R does not face with NAs), I obtain vectors with different lengths.
I read the distance correlations could lead with different length vectors. However, I have this error:
dcor.test(variable1[which(!is.na(variable1))],variable2[which(!is.na(variable2))], R=50) Error in dcov.test(x, y, index = 1, R) : Sample sizes must agree DCOR(dat$Demográficas.Age.[which(!is.na(dat$Demográficas.Age.))],dat$Demográficas.Situación.en.el.banco.[which(!is.na(dat$Demográficas.Situación.en.el.banco.))]) Error in DCOR(dat$Demográficas.Age.[which(!is.na(dat$Demográficas.Age.))], :
Sample sizes must agree
length(variable1[which(!is.na(variable1))]) = 4000 length(variable2[which(!is.na(variable2))]) = 1000
It is not possible to compare different length vectors also with distance correlation? How can I deal with that?
Thank you so much!
Here are some principal references of distance correlation: Szekely et al.(2007): http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.225.9216&rep=rep1&type=pdf The package of R I am using: https://cran.r-project.org/web/packages/energy/energy.pdfUPDATE
I tried with bcdcor (bias-corrected distance correlation), implemented in Energy and Rfast packages, and he can work with different length vectors. However, I can't understand why and how this "bias-correction" affect in the analysis/results. Some ideas?