2024-04-14

Goal

Loading the Data

  • library(ggplot2)
  • library(dplyr)
  • library(plotly)
  • library(readr)

The columns from the data set to work with include:

  • Country
  • Year
  • Annual Mean
  • 5-yr smooth
  • Code

Global Average Temperature Mean

Initial data suggests that from 1901 to 2022, there is a positive linear relationship between Time and Temperature.

global_yearly_average <- data %>%
  group_by(Year) %>%
  summarize(Average_Temperature = mean(Annual.Mean, na.rm = TRUE))
  
a <- ggplot(global_yearly_average, aes(x = Year, y = Average_Temperature)) + 
  geom_line(color = "blue") + 
  labs(title = "Global Average Annual Mean Temperature (1901-2022)", 
    x = "Year", 
    y = "Temperature (°C)") + 
  geom_smooth(method = "lm", color = "red", se = FALSE) + 
  theme_minimal()

Global Average Temperature Mean

Comparing Specific Countries

The thought process is now to check for anomalies. Picking countries to identify if there were any unusual temperature changes specific to where they may be located across the globe.

countries_of_interest <- c("USA", "RUS", "VNM", "BRA", "AUS", "SWE", "KEN")
filtered_data <- data %>%
  filter(Code %in% countries_of_interest)

# Calculate the average annual mean temperature
country_yearly_avg <- filtered_data %>%
  group_by(Year, Country) %>%
  summarise(Average_Temperature = mean(Annual.Mean, na.rm = TRUE), 
            .groups = 'drop')

# Plot the temperature trends
b = ggplot(country_yearly_avg, aes(x = Year, y = Average_Temperature, 
                                   color = Country)) +
  geom_line() +
  labs(title = "Comparison of Average Annual Mean Temperature",
       x = "Year",
       y = "Temperature (°C)") +
  theme_minimal() +
  scale_color_brewer(palette = "Dark2")  # palette

Comparing Specific Countries

Distribution Analysis

Dividing the data into two time periods, we can clearly see that there is a slight shift to the right for the later time period. This is to further illustrate how temperatures have risen over time.

Statistical Analysis

## [1] "Correlation coefficient: 0.999112510324981"
## [1] "P-value: 0"

Z score for anomalies

Threshold: 3 Standard Deviations

##               Country Year Annual.Mean X5.yr.smooth Code   z_score
## 1              Canada 1972       -6.81        -5.20  CAN -3.098106
## 2  Russian Federation 1902       -6.54        -5.54  RUS -3.065619
## 3  Russian Federation 1969       -6.50        -5.45  RUS -3.060806
## 4  Russian Federation 1912       -6.42        -5.73  RUS -3.051180
## 5              Canada 1917       -6.30        -5.55  CAN -3.036741
## 6  Russian Federation 1941       -6.22        -5.06  RUS -3.027115
## 7              Canada 1933       -6.16        -5.30  CAN -3.019896
## 8  Russian Federation 1966       -6.09        -5.33  RUS -3.011473
## 9              Canada 1950       -6.09        -5.23  CAN -3.011473
## 10             Canada 1907       -6.05        -5.50  CAN -3.006661
## 11 Russian Federation 1915       -6.03        -5.75  RUS -3.004254
## 12 Russian Federation 1987       -6.03        -4.64  RUS -3.004254
## 13 Russian Federation 1952       -6.00        -5.24  RUS -3.000644

Comparing the anomalies

The hypothesis is because Russia and Canada are closer to the North Pole, they had more extreme variations compared to a country closer to the equator, such as Mexico.

Temperature by Decade Code

Showing the temperature by decade to paint a clear picture of the general trend occuring.

data$Decade <- floor(data$Year / 10) * 10  # Create new decade column

# Calculate average temperature for each decade
decadal_temps <- data %>%
  group_by(Decade) %>%
  summarise(Average_Temperature = mean(Annual.Mean, na.rm = TRUE)) 

# Plot temperature trends by decade
c = ggplot(decadal_temps, aes(x = Decade, y = Average_Temperature)) +
  geom_line() +
  geom_point() +
  theme_minimal() +
  labs(title = "Average Temperature by Decade",
       x = "Decade",
       y = "Average Temperature (°C)")

Temperature by Decade

Variability by Decade Code

Using the Stanard Deviation by decade to determine variability as time progresses.

decadal_variability <- data %>%
  group_by(Decade) %>%
  summarise(Temperature_SD = sd(Annual.Mean, na.rm = TRUE))

# Plot the variability trends
d= ggplot(decadal_variability, aes(x = Decade, y = Temperature_SD)) +
  geom_line() +
  geom_point() +
  theme_minimal() +
  labs(title = "Temperature Variability by Decade",
       x = "Decade",
       y = "Standard Deviation of Temperature (°C)")

Variability by Decade

3d Plot for Specific Countries

Conclusion

  • From 1901-2022 the global average temperature has increased, as evidenced in mean, distribution analysis, and decade charts.
  • Variability has decreased over time, with colder countries having the most variability
  • The anomalies closer to the north pole have higher temperature fluctuations
  • Since 1970, there has been an exponential increase in temperature with a decrease in variability.

The data suggests a sharp upward trend in global temperature as evidence of accelerated climate change, however, I must acknowledge that this is only about 120 years of data in Earth’s long lifespan. These trends highlight the urgent need for decisive action to mitigate the long term impacts of climate change.