Better than Mad, Derive $Q_n$ Could someone be so kind as to walk me through how to do this equation on a dataset?
on pg 5 (marked as 1277) equation 3.3 of this paper.
$$Q_n = c|x_i-x_j|_{(k)},\;\;1\leq i<j\leq n,k\approx{n\choose 2}/4$$
 A: Let's decode this:
$Q_n = c|x_i-x_j|_{(k)},\;\;1\leq i<j\leq n,k\approx{n\choose 2}/4$
into something more like an algorithm. (Edit: This doesn't describe the actual algorithm that you'd use to code calculation of $Q_n$ up - it's just an attempt to explain what the formula means.)


*

*Consider just the inner term, "$|x_i-x_j|,\;\;1\leq i<j\leq n$":
Take all pairs of observations $(x_i,x_j),\; i<j$ and find their absolute difference.

*Now, $_{(k)}$: for $k\approx{n\choose 2}/4$, take the $k$-th of those absolute differences in order from smallest to largest (i.e. take the k-th order statistic). [Roughly speaking, find the lower quartile of those absolute differences.]

*multiply by $c$ (the default given in the paper is the asymptotic correction factor for $\sigma$ in a Gaussian, $c=1.1926$). Call the result $Q_n$.

Example:
Let's consider n=7.
There are 7$\times$6/2=21 pair-differences. Several approaches to calculating sample quantiles place the lower quartile at the 6th observation of 21 (it splits the values into the ratio 3:1 -- 5 below the quartile and 15 above it). For example, the default method in R's quantile function does this (quantile(1:21) returns 6 for the 25th percentile), and Tukey's definition of hinges does the same (fivenum(1:21) also returns 6 for the lower hinge).
Consider the data values $(18.3, 18.7, 19.2, 20.7, 22.4, 26.5, 30.1)$ (sorted for convenience).
The 21 sorted pair-differences are: $(0.4, 0.5, 0.9, 1.5, 1.7, 2, 2.4, 3.2, 3.6, 3.7, 4.1, \\\:4.1, 5.8, 7.3, 7.7, 7.8, 8.2, 9.4, 10.9, 11.4, 11.8)$
The sixth of those is $2$, so for that data, one approach to taking quartiles would put $Q_n=2c$. (I won't labour the point with multiplying by constants)
Check in R:
> x
[1] 18.3 18.7 19.2 20.7 22.4 26.5 30.1
> d = sort(abs(c(outer(x,x,"-"))[c(outer(x,x,"<"))]))
> d
 [1]  0.4  0.5  0.9  1.5  1.7  2.0  2.4  3.2  3.6  3.7  4.1  4.1  5.8  7.3
[15]  7.7  7.8  8.2  9.4 10.9 11.4 11.8
> quantile(d,p=0.25)
25% 
  2 

(Then all that remains is the multiplication by $c$, suggesting an estimated spread - essentially a robust estimate of standard deviation - of about 2.385 if we use the default $c$. As mentioned earlier, we wouldn't code a function like this for general use as it's inefficient. On small examples, like this, it's fine.)
