# Multivariant wilcox.test() in r

I know that wilcox.test it's used when you need to check if two samples of one no parametric independent variable are coming from the same population.

The thing is that r allows you to do wilcox.test(formula = W + Y + Z ~ X, data = mydata) and returns me a different value that when I use the formula Y ~ X.

What is r showing me?

Shouldn't I do a T^2 Hotteling with p-value calculated with permutations for non-parametric distributions? With is the difference between this W + Y + Z ~ X in a wilcox.test?

Thanks,

• It's adding W, Y, and Z. You can confirm this by creating a new column that's the sum of those columns, then seeing that the value of the test statistic is the same. What are you trying to do here? May 4, 2017 at 21:37
• Thanks, I assume that it would be similar to T^2 Hotteling, I mean multvariate analisis, but the point it's that it has'nt sence to me. And I wannt to know what was r doing. I acctually have some groups with 3 independent variables and I'm tring to guess if they are coming from different populations, When I add the variables p-value decrease, but I was intuit it was not correct at all do that.
– Xbel
May 4, 2017 at 22:00
• Just one additional hint: No, Wilcoxon's test is not used when "you need to check if two samples of one no parametric independent variable are coming from the same population". Firstly, there is no such thing as "parametric and non-parametric variables". Secondly, the test does exactly the contrary. It can help to identify if two groups are detectably different. The reverse is not possible. Nov 8, 2017 at 8:11

## 1 Answer

As @Peyton point, the problem is that, in contrast to other 'formula' styles, in here just add the different components of the vector.

When a formula is introduced into r function use to be in the form of: Dependent variable ~ Independent Variable 1 + Independent Variable 2, + ... + Independent Variable n. This work this way in most common and usual functions like lm(), glm() or caret package.

But it seems like wilcox.test() -despite it accept this form- is operating with variables. In the case I expose is adding it.