I would like to perform a signed-rank test on two paired, ordinal variables in R. Such a non-parametric test is required, as neither of the variables follow normal distribution. Both variables originate from a survey where respondents have to account for a situation 'before' (variable 1) and a situation 'after' (variable 2).
The sample is weighted: a variable assigns a given weight to each row. The weights are numbers with decimals. Respondents are users of different services and the weights ensure that the proportion of users of each service is the same as in a previous survey, so both surveys can be compared.
The built-in wilcox.test argument in R does not take weights into account. The 'survey' package does offer a Wilcoxon test for weighted data but it does not seem to work for paired variables.
Is there any possibility to perform a weighted Wilcoxon signed-rank test - or any alternative test with a similar function taking weights into account - in R?
As I have not found a way to perform a signed-rank test on a weighted sample (yet), I have considered and rejected solutions to get past the weighting and use the built-in wilcox.test argument:
replicating rows with respect to the values of the weighing factors, but it seems uneasy as the latter are not integers;
transforming the variables into variables with a normal distribution, but it doesn't seem wise to apply such a treatment to ordinal variables.
If there is no possibility of a weighted paired Wilcoxon test, I could consider weighing the ranks using the wtd.rank argument from the ‘Hmisc’ package: package manual says weighted ranks can be used to obtain Wilcoxon tests. Yet, is it the same thing to attribute a weight to each respondent and to weight the answers directly, i.e. change the values?
Here is some example data formatted as in the sample I am using:
ord.before = c(4, 1, 1, 2, 3, 6, 5, 7, 6, 1) #ordinal “before” variable with 7 levels
ord.after = c(2, 1, 1, 2, 5, 2, 1, 5, 3, 1) #ordinal “after” variable with 7 levels
w = c(1.3, 1.3, 0.7, 0.5, 1.5, 1.6, 1.6, 0.4, 0.4, 0.7) #weights
df = data.frame(ord.before, ord.after, w)
Thanks a million for your help!
Gautier