# How can I compare 2 means that are Laplace distributed?

I want to compare 2 sample means for 1-minute-stock returns. I assume they are Laplace distributed (already checked) and I split the returns into 2 groups. How can I check whether they are significantly different?

I think I cannot treat them like a Normal distribution, because even though they are more than 300 values, the QQ-plot shows that there is a huge difference to a Normal distribution

• Asking for code / packages is off topic here, but you do have a real statistical question buried here. You may want to edit your question to clarify the underlying statistical issue. You may find that when you understand the statistical concepts involved, the software-specific elements are self-evident or at least easy to get from the documentation. – gung Jun 19 '15 at 18:14
• When you say "different" are you interested only in the difference in means, and if so, then are you assuming the spreads are identical? – Glen_b Jun 20 '15 at 8:34
• Yes, I just want to know if the means are significantly different and I assume the distribution is identical. I don't nessecaraly assume the standard deviation to be identical, but I think that would be ok, too – Rob Jun 20 '15 at 8:51
• Please provide more details about the 1-minute-stock returns. Do you want to compare means of temporally correlated data? – Michael M Jun 20 '15 at 10:53
• Note also that the number of values you check doesn't change the distribution; you may be thinking of the distribution of sample means, which at $n=300$ for a Laplace will be very close to normal. – Glen_b Jun 20 '15 at 11:11

Assuming both Laplace distributions have the same variance,

a) the likelihood ratio test would involve a test statistic like:

$\mathcal{L}=\frac{\prod_{i=1}^n \frac{1}{2\hat{\tau}} \exp(-\frac{|x_i-\hat{\mu}|}{\hat{\tau}})}{\prod_{i=1}^{n_1}\frac{1}{2\hat{\tau}_1} \exp(-\frac{|x_i-\hat{\mu}_1|}{\hat{\tau}_1})\cdot \prod_{i=n_1+1}^{n} \frac{1}{2\hat{\tau}_2} \exp(-\frac{|x_i-\hat{\mu}_2|}{\hat{\tau}_2})}$

Taking logs, cancelling/simplifying and multiplying by $-2$.

$\,-2\mathcal{l} = 2(n\log(\hat{\tau})-n_1\log(\hat{\tau}_1)-n_2\log(\hat{\tau}_2))\;\qquad$ (where $\mathcal{l}=\log(\mathcal{L})$)

where $\hat{\tau}=m$, the mean absolute deviation from the median in the combined sample and $\hat{\tau}_i=m_i$, the mean absolute deviation from the median in sample $i$.

According to Wilks' theorem this is asymptotically distributed as $\chi^2_1$ under the null, so for a 5% test you'd reject if that exceeded $3.84\,$.

Simulation experiments suggest that the test is anticonservative at small sample sizes (the probability of rejecting is somewhat higher than nominal), but by about n=100, it seems to be at least reasonable (you get on the order of 5.3% - 5.4% rejection rate under the null for a nominal 5% test, for example; for $n_1,n_2>300$ it seems to be nearer to 5.25%).

b) We'd also expect that $\frac{\tilde{\mu}_1- \tilde{\mu}_2}{\sqrt{v}}$ would be a good test statistic (where $\tilde{\mu}$ represents the sample median and $v=2\hat{\tau}^2(\frac{1}{n_1}+\frac{1}{n_2})$); if I haven't made an error in there, in large samples like yours it would be approximately normally distributed under the null, with mean 0 and variance 1, where $\hat{\tau}^2$ could be based on the square of the mean absolute deviation from the mean in the combined sample, $m^2$, though I expect it would in practice tend to work better basing it on a sample-weighted average of the two sample $m^2_i$'s $^\dagger$ .

$\dagger$ (Edit: simulation suggests the normal approximation is fine but the variance calculation is not correct above; I can see what the problem is now but I still have to fix it. The permutation version of this test (see item (c)) should still be fine).

c) Another alternative would be to perform a permutation test based on either of the above statistics. (One of the answers here gives an outline of how to implement the permutation test for a difference in medians.)

d) You could always do a Wilcoxon/Mann-Whitney test; it will be considerably more efficient than trying to use a t-test at the Laplace.

e) Better than (d) for Laplace data would be Mood's median test; while often recommended against in books, when dealing with Laplace data it will show good power. I expect it would have similar power to the permutation version of the asymptotic test of difference in medians (one of the tests mentioned in (c)).

The question here gives an R implementation that uses a Fisher test, but that code can be adapted to use a chi-square test instead (which I'd suggest in even moderate samples); alternatively there's example code for it (not as a function) here.

The median test is discussed in Wikipedia here, though not in much depth (the linked German translation has a little more information). Some books on nonparametrics discuss it.

• Great, thanks! Can I then use the test statistic you used and reject it, if the Laplace quantile for mean=0 and standard deviation= 1 is exceeded like I would do with the Normal distribution test? – Rob Jun 20 '15 at 12:16
• I'm sorry, really I don't know what you're asking there, so you'll need to explain in detail what it is that you mean. Which test statistic are you referring to? [You should stick to the tests mentioned in (a), (c) or (d), since there's something wrong with my calculated variance in the second, asymptotic one labelled (b), as my edit marked with a "$\dagger$" states clearly. I still have to fix that case but I may not get to it quickly.. – Glen_b Jun 20 '15 at 23:12
• @Glen_b. Useful answer thanks (+1) but the null model has 2 parameters ($\hat \mu$ and $\hat \tau$) whereas the alternative has 4. So it should be $\chi^2_{ \mathbf{2} }$? (although for the small-moderate sample size case I am looking at I am tabulating values by simulation anyway) – P.Windridge Mar 20 '18 at 11:50
• Or maybe you used a single estimate for the scale in the alternative model? – P.Windridge Mar 20 '18 at 11:57
• @P.Windridge This is an excellent point. Yes, as I have the algebraic expression that's a reduction of 2 free parameters in going from the alternative to the null (but indeed I was thinking about assuming the same scale when I wrote $\chi^2_1$). I need to fix that so it's all consistent (and while I am at it I should re-work it through to fix up whatever that other issue was that I mentioned in the edit) – Glen_b Mar 20 '18 at 23:46