Dear list,
I guess this is an old question on this forum, but so far I have not found any solutions yet. Briefly speaking, I want to incorporate weight into my calculation of tie-corrected rank correlation, but neither ktau or spearman supports sampling weight. I would like to propose a solution here and hear about your opinion (I am not sure if there is any literature supporting this approach, or if there is any flaw with this approach):
1. Use fracrank to calculate fractional ranks of both variables, as fracrank allows the use of weight;
2. Use the normal command corr to calculate the Pearson's correlation between the two fractional ranks and using weight.
fracrank is a user-written command provided by Philippe Van Kerm. It can be installed from within Stata by typing "ssc install sgini". Another package, somersd (by Roger Newson), calcualtes kendall's taua and allows weight, but taua does not correct for ties.
I guess this is an old question on this forum, but so far I have not found any solutions yet. Briefly speaking, I want to incorporate weight into my calculation of tie-corrected rank correlation, but neither ktau or spearman supports sampling weight. I would like to propose a solution here and hear about your opinion (I am not sure if there is any literature supporting this approach, or if there is any flaw with this approach):
1. Use fracrank to calculate fractional ranks of both variables, as fracrank allows the use of weight;
2. Use the normal command corr to calculate the Pearson's correlation between the two fractional ranks and using weight.
Code:
sysuse auto,clear fracrank price [aw=weight], gen(rank1 , replace) fracrank mpg [aw=weight] , gen(rank2 , replace) corr rank1 rank2 [aw=weight] spearman price mpg //compare