0
$\begingroup$

I'm currently looking into methods for restoring balance of a biased dataset with respect to a continuous variable. My problem is similar to this question, with the slight difference that I'm dealing with three target variables.

I found much literature dealing with imbalanced classes, but none specifically targeting continuous variables.

Concretely, I have three normally-distributed variables, of which two are correlated:

v1 <- rnorm(10000)
pop <- data.frame(v1=v1, v2=rnorm(10000) + v1, v3=rnorm(10000))

Then I draw a biased sample:

biased <- pop[sample(1:nrow(pop), 1000, replace=F, prob=(4+pop$v1)^2) ,]

Leading to these distributions (red is population, blue is biased): enter image description here

As expected, the biased sample is shifted towards higher values of v1 and v2, and not biased w.r.t. v3.

I then calculate the density ratios and use them as weights to draw a subsample from the biased subsample that (hopefully) matches the population distribution:

library(densratio)
dr <- densratio(pop, biased)
wt <- dr$compute_density_ratio(biased)
balanced <- biased[sample(1:nrow(biased), 500, replace=T, prob=wt),]

This leads to these distributions (green is balanced):

enter image description here

As you can see, the "balanced" distribution is only vaguely similar to the population distribution. I tested some apporoaches, e.g. using a 3d kernel estimator, only matching for v1, etc, but none were quite satisfying. Of course I know that a perfect match can't be expected, but I'm not quite sure if I'm missing anything.

Similar to the original question, I can't find any sources on this kind of balancing method. Is this too trivial to be even discussed? Or is there something wrong about this approach? Also, are there other techniques (e.g. using artificial samplings) to restoring balance w.r.t (three) continuous target variables?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.