Wilcoxon tests as linear models in R

141 views Asked by At

I found some suggestions throughout the web that suggest that most common statistical tests can be performed using general(ized) linear models (cf. here). The author suggests to first transform the data into signed ranks (as the wilcoxon test does) and then perform a linear model:

signed_rank = function(x) sign(x) * rank(abs(x))

# one-sample test
summary(lm(signed_rank(y) ~ 1))

# two-sample test
summary(lm(signed_rank(z - y) ~ 1)

However, due to this rank transformation, the residuals of the linear models are then of course no longer normal. Thus, this general assumption of linear models is not fulfilled. Thus, I wonder whether you can suggest an GLM (generalized linear model) alternative. How would the code look like in R?

Thank a lot for your help in advance!

0

There are 0 answers