# How to test for significance between median values of a variable between two conditions?

I am comparing the median values of "A" between two conditions? The samples are taken from different groups, for the variable A. How can I test for significance for this median values?

• As in height measurements of 67 plants with fertilizer A vs 41 plants with fertilizer B? – Dave Jun 5 at 11:48
• – user2974951 Jun 5 at 11:49
• @user2974951 rdrr.io/cran/MultNonParam/man/mood.median.test.html not good enough – amarykya_ishtmella Jun 5 at 12:03
• @Dave exactly!! I'm looking at, let's say the height of these plants A and B. – amarykya_ishtmella Jun 5 at 12:05
• That Wikipedia article on Mood’s test gives some alternatives and their advantages and disadvantages. Permutation testing or bootstrap confidence intervals could make sense, too. However, why you’re interested in the median matters. Why compare medians? Why not t-test the means? – Dave Jun 5 at 12:17

## 1 Answer

Mood's median test could be used for this, but if this is not good enough you could try quantile regression, where you can specify exactly which quantile you want. Below is an example in R for some made up data.

library(quantreg)

A=c(1,2,3,4,5,6,6,6,7,8,9,10)
B=c(1,1,1,1,6,6,6,6,6,10,10,10)
df=data.frame(value=c(A,B),
group=c(rep("A",length(A)),rep("B",length(A))))

summary(rq(value~group,data=df),se="boot")

Call: rq(formula = value ~ group, data = df)

tau: [1] 0.5

Coefficients:
Value   Std. Error t value Pr(>|t|)
(Intercept) 6.00000 0.81290    7.38100 0.00000
groupB      0.00000 1.75195    0.00000 1.00000
Warning message:
In rq.fit.br(x, y, tau = tau, ...) : Solution may be nonunique

• The “quantile you want” is the default of tau=0.5. This is what I meant in my comment by bootstrap confidence intervals, too, as I think quantreg’s default confidence intervals are calculated via bootstrap. – Dave Jun 5 at 12:20
• @Dave thank you so much.!! – amarykya_ishtmella Jun 8 at 6:25
• @user2974951 this worked pefectly :) Thank you – amarykya_ishtmella Jun 8 at 6:26