Data overview:
This analysis used data on earthquake reports starting in 1638 and ending in 1985. The dataset is a composition of reports from various sources, compiled on Kaggle.com by Qahramon Uktamov. Any sampling bias that could arise within this data would likely be attributed to the multiple different sources from which the earthquake reports were compiled. Other biases that may exist within this data are related to reporting bias. Many of the earthquakes recorded in this dataset are based off of citizen report, and could be biased against earthquakes of lower severity. Earthquakes of higher magnitude may be more likely to be reported by citizens, and earthquakes of lower magnitude may even go completely unnoticed. We were initially interested in this dataset because of how far back it went, although the data from the 1600s through the early 1900s was missing values in most of the columns. We were excited to create maps of earthquakes based on the variables found in the dataset to explore where earthquakes are more severe, and if it matches what we expect.
Primary dataset: https://www.kaggle.com/datasets/qahramonuktamov2205/earthquake-intensity-dataset
The dataset contains:
Year, month, day, hour, minute, and second of event recording in UTC and hours behind UTC
Latitude and longitude of event
Richter magnitude, depth of earthquake, and Modified Mercalli Intensity
Distance of recording from epicenter, latitude and longitude of recording, and name of location of recording
Event recording/reporting entity
Additional data:
An additional dataset was included to test the classification models on recent data. These data are published by the US Geological Survey on Kaggle.com and contain significant (magnitude ≥5) earthquakes between 1965 and 2016.
Secondary dataset: https://www.kaggle.com/datasets/usgs/earthquake-database/data
| Name | earthquakes |
| Number of rows | 157015 |
| Number of columns | 20 |
| _______________________ | |
| Column type frequency: | |
| character | 5 |
| numeric | 15 |
| ________________________ | |
| Group variables | None |
Variable type: character
| skim_variable | n_missing | complete_rate | min | max | empty | n_unique | whitespace |
|---|---|---|---|---|---|---|---|
| unpub_or_grouped_int | 136045 | 0.13 | 1 | 1 | 0 | 2 | 0 |
| state | 304 | 1.00 | 2 | 4 | 0 | 66 | 0 |
| city | 214 | 1.00 | 3 | 29 | 0 | 20306 | 0 |
| source | 0 | 1.00 | 1 | 1 | 0 | 13 | 0 |
| country | 0 | 1.00 | 3 | 19 | 0 | 7 | 0 |
Variable type: numeric
| skim_variable | n_missing | complete_rate | mean | sd | p0 | p25 | p50 | p75 | p100 | hist |
|---|---|---|---|---|---|---|---|---|---|---|
| year | 0 | 1.00 | 1957.65 | 21.64 | 1638.00 | 1945.00 | 1961.00 | 1975.00 | 1985.00 | ▁▁▁▁▇ |
| month | 16 | 1.00 | 6.65 | 3.44 | 1.00 | 4.00 | 7.00 | 10.00 | 12.00 | ▇▅▅▅▇ |
| day | 37 | 1.00 | 15.66 | 8.92 | 1.00 | 8.00 | 16.00 | 23.00 | 31.00 | ▇▆▇▆▆ |
| hour | 753 | 1.00 | 11.13 | 6.83 | 0.00 | 5.00 | 11.00 | 17.00 | 23.00 | ▇▇▆▇▆ |
| minute | 883 | 0.99 | 29.03 | 17.45 | 0.00 | 14.00 | 30.00 | 44.00 | 59.00 | ▇▇▇▇▇ |
| second | 32946 | 0.79 | 28.99 | 17.04 | 0.00 | 14.00 | 29.00 | 43.30 | 59.90 | ▆▇▆▇▆ |
| local_to_utc | 6466 | 0.96 | 7.43 | 1.35 | 4.00 | 7.00 | 8.00 | 8.00 | 11.00 | ▂▁▇▁▁ |
| latitude | 14932 | 0.90 | 38.74 | 7.00 | 4.60 | 35.00 | 37.84 | 42.02 | 68.41 | ▁▁▇▂▁ |
| longitude | 14932 | 0.90 | -112.19 | 21.59 | -180.00 | -121.82 | -118.38 | -104.80 | 179.90 | ▇▃▁▁▁ |
| magnitude | 46831 | 0.70 | 5.02 | 1.17 | 0.50 | 4.30 | 5.00 | 5.80 | 8.70 | ▁▂▇▃▁ |
| eq_depth | 99609 | 0.37 | 14.51 | 16.96 | 1.00 | 6.00 | 10.00 | 16.00 | 519.00 | ▇▁▁▁▁ |
| epidist | 16353 | 0.90 | 145.29 | 200.46 | 0.00 | 38.00 | 90.00 | 179.00 | 9930.00 | ▇▁▁▁▁ |
| city_lat | 1560 | 0.99 | 38.89 | 7.34 | 6.30 | 34.94 | 37.92 | 42.33 | 71.30 | ▁▁▇▁▁ |
| city_lon | 1560 | 0.99 | -112.57 | 22.01 | -176.75 | -121.94 | -118.20 | -105.52 | 179.23 | ▇▂▁▁▁ |
| mmi | 26287 | 0.83 | 3.82 | 1.12 | 1.00 | 3.00 | 4.00 | 4.00 | 12.00 | ▆▇▁▁▁ |
When cleaning the data in R, we discovered that many reports were recorded for each earthquake. This meant that the same earthquake could be recorded within the data dozens of times, generally at diffferent sites. To mitigate this, we were able to eliminate repeating reports in our cleaned dataset by grouping by date, time, and latitude/longitude (all of which were identical between reports of the same earthquake), and summarizing these groups. Other data cleaning included removing NA/missing values and non-US values, removing columns that were unimportant for this analysis, and reformatting the date and time. After cleaning, we were left with data from 1904 to 1985.
First, the entire dataset was cleaned.
| No | Variable | Stats / Values | Freqs (% of Valid) | Valid | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | datetime_utc [POSIXct, POSIXt] |
|
6645 distinct values | 49760 (100.0%) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | lat [numeric] |
|
1754 distinct values | 49760 (100.0%) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | lon [numeric] |
|
2203 distinct values | 49760 (100.0%) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | magnitude [numeric] |
|
71 distinct values | 49760 (100.0%) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | eq_depth [numeric] |
|
161 distinct values | 49760 (100.0%) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | mmi [numeric] |
|
11 distinct values | 49760 (100.0%) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | state [character] |
|
|
49760 (100.0%) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | country [character] | 1. USA |
|
49760 (100.0%) |
Generated by summarytools 1.0.1 (R version 4.3.1)
2023-12-11
An additional summarized data frame for only earthquake origin points was created.
| No | Variable | Stats / Values | Freqs (% of Valid) | Graph | Valid | ||||
|---|---|---|---|---|---|---|---|---|---|
| 1 | datetime_utc [POSIXct, POSIXt] |
|
6645 distinct values | 6672 (100.0%) | |||||
| 2 | lat [numeric] |
|
1754 distinct values | 6672 (100.0%) | |||||
| 3 | lon [numeric] |
|
2203 distinct values | 6672 (100.0%) | |||||
| 4 | mag [numeric] |
|
71 distinct values | 6672 (100.0%) | |||||
| 5 | avg_mmi [numeric] |
|
225 distinct values | 6672 (100.0%) | |||||
| 6 | depth [numeric] |
|
163 distinct values | 6672 (100.0%) | |||||
| 7 | max_mmi [numeric] |
|
11 distinct values | 6672 (100.0%) |
Generated by summarytools 1.0.1 (R version 4.3.1)
2023-12-11
This graph maps the magnitude of earthquake events across the US, where the points reflect the location of the origin of the earthquake.
Figure 3.1 is a map showing the frequency and magnitude of earthquakes across the United States from 1906 to 1985. Magnitude is displayed in Richter Scale units (ergs). We can see several seismic hot spots on the West Coast, along the entire Alaskan peninsula, and in Hawaii. Alaska contains the highest concentration of severe earthquakes, many ranging from 6 to 8 in magnitude. Seismic activity is focused in these areas, but many smaller earthquakes, falling lower on the Richter Scale, are scattered through the rest of the country — mainly in New England and on the East Coast, as well as in several small areas across the Midwest.
This graph maps the depth of earthquake events across the US, where the points reflect the location of the origin of the earthquake.
Figure 3.2 displays another US map, showing the distribution of earthquake depths (in km). The deepest earthquakes occurred in Alaska. Most other earthquakes recorded across the United States have a depth of 100 km or shallower, where Alaska has experienced a high concentration of earthquakes over 100 km deep, and as deep as 200 km. These notable depths, along with the uniquely high magnitudes recorded in Alaska suggest an association between earthquake depth and earthquake magnitude. The frequency of earthquakes in Alaska is also likely due to its proximity to a tectonic boundary. Surprisingly, earthquakes that occurred in California did not have notably high depths.
This graph will show average magnitude of earthquakes by state during the included period.
Figure 3.3 shows the average magnitude of earthquakes that have occurred in each state. Surprisingly, the average magnitude is highest in Washington D.C. Upon examining the data, we found that a total of two earthquakes occurred in Washington D.C. between 1906 and 1985 — one with a magnitude of 4.4, and one with a magnitude of 7. This large and unexpected earthquake explains the interesting results in Figure 3. Alaska, although a hotspot for severe earthquakes, has the sixth highest average magnitude. This could be attributed to the frequency of seismic activity in Alaska. Earthquakes with a lower magnitude lower the mean in Alaska, where other states that have fewer reports have a higher mean.
This graph will show a total count of earthquakes by state during the period included in the data to explore which states experience the highest frequencies of earthquakes.
Figure 3.4 displays a total count of earthquakes per state. Unsurprisingly, California emerges with the highest frequency of earthquakes, with Hawaii and Alaska as a distant second and third. The extremely high volume of earthquakes in California could be partially attributed to the large area of the state of California. However, it could also be highly related to the presence of the San Andreas Fault, which runs down almost the entire western coast of California. The San Andreas Fault is a highly active tectonic fault. Faults and rifts between tectonic plates are known to be epicenters of seismic activity, so the large volume of earthquakes concentrated around and near the San Andreas Fault in California is expected.
This graph will display the monthly distribution of earthquakes in the dataset.
Our final figure is a density chart displaying a total count of earthquakes from 1906 to 1985 by month. The purpose of this figure is to explore the idea of whether there is an “earthquake season.” There does appear to be a pattern within the density chart, with October being the peak month for earthquake occurrence. However, a more in-depth time series analysis would need to be performed to truly determine whether earthquake occurrences have a seasonal component. If there were an earthquake season, it’d be October.
For this dataset, we chose to use a classification tree to model whether a given earthquake occurred in California or Alaska, as these are the two states with the highest frequency and severity of earthquakes.
To do so, a random sample of data for California and Alaska was selected. The decision to only include 2,000 observations was based on an assessment of terminal node count in pruned tree; 2,000 was found to be suitable (resulted in fewer than 15 terminal nodes).
## # A tibble: 2,000 × 3
## state magnitude eq_depth
## <chr> <dbl> <dbl>
## 1 CA 6.2 12
## 2 CA 4 4
## 3 CA 3.6 6
## 4 CA 4.8 12
## 5 CA 4.7 7
## 6 CA 6.7 10
## 7 CA 3.8 8
## 8 CA 6.2 8
## 9 CA 4.8 6
## 10 CA 3 5
## # ℹ 1,990 more rows
First, an unpruned classification tree was built. The explanatory variables selected were magnitude and depth of event. The splitting criterion used was information gain. It had a total of 97 splits.
## CP nsplit rel.error xerror xstd
## 8 0.001818182 37 0.10909091 0.2181818 0.02774143
## 9 0.001212121 53 0.08000000 0.2109091 0.02728921
## 10 0.001038961 59 0.07272727 0.2145455 0.02751637
## 11 0.000000000 66 0.06545455 0.2181818 0.02774143
## 12 -1.000000000 97 0.06545455 0.2181818 0.02774143
Then, a pruning point of the complexity parameter was calculated to build the simplest well-fitted tree.
| xerror cutoff value | CP pruning point |
|---|---|
| 0.2381983 | 0.005454545 |
The pruned tree was built using the calculated pruning point.
The pruned tree had 8 splits.
The classification tree was evaluated against the model data.
## Confusion Matrix and Statistics
##
## Reference
## Prediction AK CA
## AK 223 2
## CA 52 1723
##
## Accuracy : 0.973
## 95% CI : (0.9649, 0.9797)
## No Information Rate : 0.8625
## P-Value [Acc > NIR] : < 2.2e-16
##
## Kappa : 0.8767
##
## Mcnemar's Test P-Value : 2.592e-11
##
## Sensitivity : 0.8109
## Specificity : 0.9988
## Pos Pred Value : 0.9911
## Neg Pred Value : 0.9707
## Prevalence : 0.1375
## Detection Rate : 0.1115
## Detection Prevalence : 0.1125
## Balanced Accuracy : 0.9049
##
## 'Positive' Class : AK
##
This classification had a balanced accuracy of 90.5%; balanced accuracy is more relevant for this dataset due to an imbalance between observations for California and Alaska.
A new dataset with significant earthquake (magnitude 5.5 or greater) recordings was used to test the model against observations outside of the data window. Rough latitude/longitude areas were used to categorize recordings by state.
## # A tibble: 470 × 7
## date time latitude longitude eq_depth magnitude state
## <date> <time> <dbl> <dbl> <dbl> <dbl> <chr>
## 1 1986-01-18 01:59:02 51.6 -173. 33 5.6 AK
## 2 1986-01-26 19:20:51 36.8 -121. 8.15 5.5 CA
## 3 1986-03-06 04:08:19 56.3 -154. 33 5.5 AK
## 4 1986-03-09 13:49:28 54.3 -168. 33 5.7 AK
## 5 1986-03-21 23:56:19 54.3 -122. 18 5.5 AK
## 6 1986-03-31 11:55:00 37.5 -122. 9.17 5.6 CA
## 7 1986-03-31 11:55:40 37.5 -122. 8.50 5.7 CA
## 8 1986-04-11 17:22:21 54.2 -168. 33 6 AK
## 9 1986-05-07 20:43:31 51.4 -175. 22.1 6.3 AK
## 10 1986-05-07 22:47:11 51.5 -175. 33 8 AK
## # ℹ 460 more rows
Predictions and the resulting confusion matrix were created.
## Confusion Matrix and Statistics
##
## Reference
## Prediction AK CA
## AK 268 0
## CA 147 55
##
## Accuracy : 0.6872
## 95% CI : (0.6432, 0.7289)
## No Information Rate : 0.883
## P-Value [Acc > NIR] : 1
##
## Kappa : 0.2991
##
## Mcnemar's Test P-Value : <2e-16
##
## Sensitivity : 0.6458
## Specificity : 1.0000
## Pos Pred Value : 1.0000
## Neg Pred Value : 0.2723
## Prevalence : 0.8830
## Detection Rate : 0.5702
## Detection Prevalence : 0.5702
## Balanced Accuracy : 0.8229
##
## 'Positive' Class : AK
##
The original model was found to be 82.3% accurate for predicting states in the new data.
To better assess a classification tree model for predicting state of earthquake observation in a new dataset, a new model was created with new data cleaning on the original dataset to match the new data.
The original dataset was cleaned to only include earthquakes that the USGS defines as significant (magnitude 5.5 or greater). Again, a random slice was selected. Again, only 2,000 observations were included; in this case, this decision was made in order to match the complexity of the original model by not adding or subtracting any observations.
## # A tibble: 2,000 × 3
## state magnitude eq_depth
## <chr> <dbl> <dbl>
## 1 CA 5.5 17
## 2 CA 5.7 4
## 3 AK 6.7 8
## 4 CA 6.5 16
## 5 CA 5.7 4
## 6 AK 5.7 60
## 7 CA 5.6 7
## 8 CA 6.1 5
## 9 CA 6.2 16
## 10 CA 5.7 1
## # ℹ 1,990 more rows
Another classification tree was built with the new data. The explanatory variables selected were magnitude and depth of event. The splitting criterion used was information gain. It had a total of 36 splits.
## CP nsplit rel.error xerror xstd
## 7 0.003378378 19 0.05405405 0.08108108 0.01645100
## 8 0.001689189 25 0.03378378 0.06081081 0.01426860
## 9 0.001126126 30 0.02364865 0.04391892 0.01214126
## 10 0.000000000 33 0.02027027 0.04391892 0.01214126
## 11 -1.000000000 36 0.02027027 0.04391892 0.01214126
Once again, a pruning point of the complexity parameter was calculated to build the simplest well-fitted tree.
| xerror cutoff value | CP pruning point |
|---|---|
| 0.05606018 | 0.005454545 |
The pruned tree was built using the calculated pruning point.
The pruned tree had 11 splits.
Predictions and the resulting confusion matrix were created for the new classification tree.
## Confusion Matrix and Statistics
##
## Reference
## Prediction AK CA
## AK 303 3
## CA 112 52
##
## Accuracy : 0.7553
## 95% CI : (0.7139, 0.7935)
## No Information Rate : 0.883
## P-Value [Acc > NIR] : 1
##
## Kappa : 0.3633
##
## Mcnemar's Test P-Value : <2e-16
##
## Sensitivity : 0.7301
## Specificity : 0.9455
## Pos Pred Value : 0.9902
## Neg Pred Value : 0.3171
## Prevalence : 0.8830
## Detection Rate : 0.6447
## Detection Prevalence : 0.6511
## Balanced Accuracy : 0.8378
##
## 'Positive' Class : AK
##
Using data more closely matched to the newer data, the accuracy of the model was only slightly greater than that of the original model, at 83.8% (vs. 82.3%).
The intent of this analysis was to explore historical trends in earthquakes across the US and model predictions for where, by US state, earthquakes of different types occur. A classification tree model was used to predict earthquake location between California and Alaska, two of the states most frequently affected by earthquakes. This model was checked against the original training dataset, resulting in an accuracy of 90.5%, and against a dataset of recent earthquakes, with an accuracy of 82.4%. Additionally, the model training was adjusted to only include significant earthquakes, and its accuracy against recent earthquakes increased to 83.8%.
The data cleaning needs for this exploration resulted in the removal of a significant number of earthquakes, reducing the sample size to about a third of the original data. Less rigorous data cleaning could result in discovery of different trends when earlier earthquakes are included. Additionally, the primary dataset included many duplicate reports which, while their origin data seemed consistent, may introduce additional error. The USGS data is much cleaner and more consistent than the primary dataset and may be a more useful training dataset.