Background and data. An earthquake of magnitude 5.17 stuck near Yountville, California in the early morning hours of September 9, 2000, injuring about 25 people and doing about $50 million damage. The magnitudes of 24 smaller earthquakes nearby are given in the vector
Mag below. The first 12 occurred within the few hours before the big quake and the last 12 occurred within a few hours after.
The issue is whether the Before and After quakes differ significantly from each other in magnitude.
Mag=c(1.00, 1.14, 1.05, 1.79, 1.64, 2.76, 1.42, 1.30, 1.14, 0.96, 1.62, 1.40, 2.06, 1.64, 1.87, 1.41, 1.18, 1.59, 0.95, 1.54, 2.00, 1.16, 0.93, 1.90)
The two boxplots below show magnitudes of these two groups of earthquakes. Within the boxes, vertical lines show the sample medians and dots show their sample means. The outlier at 2.76 among those before the main quake might be called a foreshock. The quakes that occurred after the main one include some mild aftershocks.
Traditional tests may be inappropriate. We wish to test $H_0: \mu_B = \mu_A$ against $H_a: \mu_B \ne \mu_A.$
Because the general population of California earthquake magnitudes is known to be distinctly right-skewed and our samples are small, one may be reluctant to use a two-sample t test to determine whether the two population means differ. (This test, which assumes normal data, gives the p-value 0.66, indicating no significant difference.)
Ordinarily, the substitute would be a Mann-Whitney-Wilcoxon nonparmatric rank sum test, which tests whether population medians are equal. However, tied magnitudes (with values 1.14 and 1.64) would require adjustments in order test whether the population medians are equal (it shows an approximate p-value of 0.42). (And there are other quibbles with the applicability of the MWW test.) By contrast, there are no problematic assumptions for permutation tests.
Our purpose here is use appropriate $permutation\: tests$ to see whether the Before and After populations differ, and to compare the results of permutation tests with those for the t and MWW tests.