Earthquakes and Moon Phase Correlation

Download all earthquake data in the USGS database in the time frame of Jan 1 1975 and Jan 1 2005 (before spike of hydraulic fracturing and after inception of current measuring practices) of magnitude higher than 5.5 of any depth. This data was downloaded from https://earthquake.usgs.gov.

data=Import["query 5+ any depth.csv"]

Length[data]-1

data1=data[[2;;All,{1,5}]]

dates=Table[DateObject[StringDrop[data1[[i,1]],-1],TimeZone->"UTC"],{i,1,Length[data1]}]

Find the Moon phase for each and every one of those earthquakes following model. Plot the time series.

mp=MoonPhase[dates,"Name"][[2]][[1,1]];

l=Union[mp]

wholemp=MoonPhase[DateRange[{1975,1,1},{2005,1,1}],"Icon"]["Values"];

Length[Union[wholemp]]

Length[DateRange[{1975,1,1},{2005,1,1}]]

moon=ReplaceAll[mp,{l[[1]]->4,l[[2]]->1,l[[3]]->5,l[[4]]->8,l[[5]]->7,l[[6]]->3,l[[7]]->6,l[[8]]->2}]

Length[moon]

DateListPlot[ts1=TimeSeries[Transpose[{dates,moon}]],PlotLabel->"Moon Phases at Earthquake Timings",ImageSize->Large]

Find the magnitude for each and every one of those earthquakes. Plot the time series.

mag=data1[[All,2]];

DateListPlot[ts2=TimeSeries[Transpose[{dates,mag}]],PlotRange->All,PlotLabel->"Magnitudes at Earthquake Timings",ImageSize->Large]

Test the hypothesis  that there is 0 correlation between the values of the two graphs through the Spearman’s rho Rank Test.

ListPlot[Transpose[{ts1["Values"],ts2["Values"]}],PlotRange->All]

h=CorrelationTest[Transpose[{ts1["Values"],ts2["Values"]}],0,"HypothesisTestData"]

h["PValue"]

h["TestStatistic"]

SpearmanRho[ts1["Values"],ts2["Values"]]

HoeffdingDTest[ts1["Values"],ts2["Values"]]

Make Histograms of the Magnitudes at Each Moon Phase

groups=SortBy[GroupBy[Transpose[{ts1["Values"],ts2["Values"]}],First],First];

BoxWhiskerChart[Table[groups[[i,All,2]],{i,1,8}],{"Diamond",{"MeanDiamond",1,Pink}}]

Export["results3.jpg",%]

Table[Length[groups[[i]]],{i,1,8}]

ListPlot[%,PlotRange->All]

Histogram[groups[[1,All,2]]]

Histogram[groups[[2,All,2]]]

Histogram[groups[[3,All,2]]]

Histogram[groups[[4,All,2]]]

Histogram[groups[[5,All,2]]]

Histogram[groups[[6,All,2]]]

Histogram[groups[[7,All,2]]]

Histogram[groups[[8,All,2]]]

Table[Join[{i},SortBy[N[Tally[groups[[i,All,2]]]],First]],{i,1,8}]//TableForm

Export["results1.jpg",%]

Table[MatrixPlot[SortBy[N[Tally[groups[[i,All,2]]]],First],FrameTicks->None,Frame->False,ImageSize->Large],{i,1,8}]

Export["results.jpg",%]

SystemOpen["results.jpg"]

SystemOpen[DirectoryName[AbsoluteFileName["results.jpg"]]]