This project analyzes earthquake mainshocks and their aftershocks using a dataset collected from the Atacama Fault Zone.
Show code
library(readr)library(ggplot2)
Warning: package 'ggplot2' was built under R version 4.4.3
Show code
midterm1 <-read_csv("midterm1.csv")
Rows: 110 Columns: 2
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
dbl (2): aftershock, mainshock
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Show code
# residual diagnositics with no transformationx= midterm1$mainshocky= midterm1$aftershockmodel =lm(y~x)plot(x,y)abline(lm(y~x))
Call:
lm(formula = gy ~ x)
Residuals:
Min 1Q Median 3Q Max
-0.52350 -0.17697 0.00849 0.21145 0.68690
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.96201 0.11021 -8.729 3.55e-14 ***
x 0.96168 0.03657 26.297 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.258 on 108 degrees of freedom
Multiple R-squared: 0.8649, Adjusted R-squared: 0.8637
F-statistic: 691.5 on 1 and 108 DF, p-value: < 2.2e-16
Show code
par(mfrow=c(2,2))plot(model_bc)
Show code
library(ggplot2)ggplot(midterm1, aes(x = mainshock, y = aftershock)) +geom_point() +geom_smooth(method ="lm", se =FALSE, color ="red", linetype ="dashed") +theme_minimal(base_size =14) +labs(x ="Mainshock Magnitude", y ="Aftershock Magnitude",title ="Initial Relationship Between Mainshock and Aftershock")
`geom_smooth()` using formula = 'y ~ x'
Scatterplot of Mainshock vs Aftershock Magnitudes
PART B
mainshock of magnitude 5.0 is expected to be followed by an aftershock of around 6.27 magnitude, with 95% confidence that the true mean aftershock lies between 6.01 and 6.53.
This supports the idea that as mainshock magnitude increases, the aftershock magnitude also tends to rise in a predictable, nearly linear way.
For a mainshock of magnitude 5.0, we are 95% confident that the next aftershock will fall between 5.45 and 7.07 in magnitude.
This indicates that while a 6.0 aftershock is quite plausible, magnitudes as low as 5.4 or as high as 7.0 could also reasonably occur, given the natural variability in the data.