How many « degrees of freedom » should a Wilcoxon rank-sum test have? I would like to perform a Mann-Whitney U Test (also called Wilcoxon rank-sum test) on a weighted sample in R. Such a non-parametric test is required, as neither of the two variables used follow normal distribution. The sample is weighted: a variable assigns a given weight to each row. The weights are numbers with decimals.
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 I am puzzled by the “degree of freedom” value I get upon performing it. Here is an example, with data formatted like my actual data:
install.packages(‘survey’)
library(survey)
ordinal = c(4, 1, 1, 2, 3, 6, 5, 7, 6, 1) #outcome variable: ordinal variable with 7 levels
groups = c(1, 1, 2, 2, 2, 2, 2, 1, 1, 2) #groups variable: factor with 2 levels
w = c(1.3, 1.3, 0.7, 0.5, 1.5, 1.6, 1.6, 0.4, 0.4, 0.7) #weights
data = data.frame(ordinal, groups, w)
data$groups<-as.factor(data$groups)....sd <- svydesign(ids=~1, probs=data$w, data=data) #survey design, used to apply weights to test
svyranktest(ordinal~groups, sd, test="wilcoxon")

Test result is displayed as follows:
Design-based KruskalWallis test

data:  ordinal ~ groups

t = -2.5834, df = 8, p-value = 0.03244

alternative hypothesis: true difference in mean rank score is not equal to 0

sample estimates:

difference in mean rank score 
                   -0.3626219

Does it make sense that the test’s degree of freedom equals to 8? Or should it rather equal to 1, i.e. the amount of groups minus 1?
In a Kruskal-Wallis test, the degree of freedom is the amount of groups minus 1. I would have expected the degree of freedom in the Mann-Whitney test to be calculated the same way, as both test are very like-minded.
Yet, in this discussion thread, someone says "I suppose you could say the  sample sizes are the 'degrees of freedom'", but I am not sure whether this applies to rank-sum tests (independent variables) and/or to signed-rank tests (paired variables).
From what I have also read on the internet, I get a sense that “degrees of freedom” don’t mean much when applied to a rank-sum test, yet I would really like to know whether the test is correct the way I perform it.
 A: For this design-based Wilcoxon (rank-sum) test, the degrees of freedom are the design degrees of freedom: the number of primary sampling units in the design minus the number of strata.  These are denominator degrees of freedom for a $t$ or $F$ distribution. In this case, with two groups, it's a $t$ distribution. (With more than two groups there would also be a numerator degrees of freedom for an $F$ distribution, which would be one less than the number of groups; this numerator df is analogous to the df for the $\chi^2$ approximation to the Kruskal-Wallis test)
The use of design degrees of freedom in a central-limit-theorem approximation is very common in survey analysis. Simulations in the paper proposing these design-based rank tests (Lumley, T., & Scott, A. J. (2013). Two-sample rank tests under complex sampling. BIOMETRIKA, 100 (4), 831-842.) show that using the t distribution and approximate degrees of freedom gives better performance.  
In this particular case the primary sampling units are the individual observations, and there is only one stratum, so the df is 8-1=7.
I should note that whether this test is what you want depends on what your weights are.  svyranktest is for sampling weights, and it compares estimated population ranks rather than comparing sample ranks giving some observations more weight. The test is not exact in small samples.
The data and weights given look unusual for a probability sample -- at the very least, the weights must have been scaled, since sampling weights must be 1 or greater. 
A: The Wilcoxon signed rank test actually does not require a degrees of freedom. In essence, the Wilcoxon signed rank test is evaluating whether or not the median of the differences is equal to 0, so this allows us to use the Central Limit Theorem and a z-score for the test statistic. Using the normal distribution gets rid of the need for a df. That  being said, I am not sure why R is returning a df for this test.
