Dear Stata Users,

I am trying to test for sorting of individuals across the threshold in an RD setting. In order to make my sample representative I need to apply weights, nevertheless -rddensity- and -rdbwdensity- (the commands I found to be most commonly used for this purpose) don't accept them. Therefore, if I run the commands without specifying weights the density across the threshold is not representative of the true one.

My data looks like:
id income factor
1 1149.2 3
2 1029.4 4
3 1345.62 6
4 674.2 6
5 886.36 1
... ... ...
Assume that there is a discontinuity at let's say income=1000 the idea would be to estimate the density of population at both sides of the threshold in order to test for manipulation on the density discontinuity.

The command I have on mind would be annalogous to the the following (if weights were allowed):

rddensity income [fw=factor], c(1000) bwselect(each)

My question is: Is there a way I can get around this problem or a well stablished command with similar purpose than -rddensity- but allowing for weights?

Thank you very much in advance for any useful thoughts on this issue.