Introduction to Statistics

The effect of Carbon Dioxide on Global Temperature

Loan Huynh - 3655461

Last updated: 22 October, 2017

Introduction

Problem Statement

Data

climate_change <- read.csv(file = "climateChange_sample.csv")
climate_change

Descriptive Statistics and Visualisation

summaryTable <- climate_change %>%  summarise(variable = "Global Temperature",
                              Mean = mean(Global_Temperature_avg, na.rm = TRUE),
                              Min = min(Global_Temperature_avg, na.rm = TRUE),
                              Max = max(Global_Temperature_avg, na.rm = TRUE),
                              Median = median(Global_Temperature_avg, na.rm = TRUE),
                              Q1 = quantile(Global_Temperature_avg, probs = .25, na.rm = TRUE),
                              Q3 = quantile(Global_Temperature_avg, probs = .75, na.rm = TRUE),
                              SD = sd(Global_Temperature_avg, na.rm = TRUE),
                              n = n(),
                              Missing = sum (is.na(Global_Temperature_avg)))
summaryTable <- rbind(summaryTable, climate_change %>%  summarise(variable = "CO2",
                              Mean = mean(CarbonDioxide_avg, na.rm = TRUE),
                              Min= min(CarbonDioxide_avg, na.rm = TRUE),
                              Max= max(CarbonDioxide_avg, na.rm = TRUE),
                              Median= median(CarbonDioxide_avg, na.rm = TRUE),
                              Q1 = quantile(CarbonDioxide_avg, probs = .25, na.rm = TRUE),
                              Q3 = quantile(CarbonDioxide_avg, probs = .75, na.rm = TRUE),
                              SD = sd(CarbonDioxide_avg, na.rm = TRUE),
                              n = n(),
                              Missing = sum(is.na(CarbonDioxide_avg))))
knitr::kable(summaryTable)
variable Mean Min Max Median Q1 Q3 SD n Missing
Global Temperature 0.3016949 -0.20 0.99 0.28 0.055 0.55 0.2882776 59 0
CO2 351.9347458 315.28 404.21 349.20 328.565 372.21 26.3742182 59 0
boxplot(x = climate_change$Global_Temperature_avg, main = "The change in global surface temperature",
        ylab = "Temperature Change (Census degree)")

boxplot(x = climate_change$CarbonDioxide_avg, main = "Carbon Dioxide",
        ylab = "CO2 (parts per million)")

Decsriptive Statistics Cont.

library(plotly)
temp <- climate_change %>% select("Year", "Global_Temperature_avg")
plot_ly(temp, x = ~Year, y = ~Global_Temperature_avg, x.format= "%Y")  %>%  add_lines(y = ~Global_Temperature_avg) %>% 
  layout(xaxis = list(title = "Year"),
         yaxis = list(title = "Temperature Anomaly (C)"),
         title = "Fig1: The change in global surface temperature between 1958-2016 ")

- The above Figure 1 shows that the change of annual global surface temperature fluctuated between 1958 and 2016 and has upward trend in recent years.

carb <- climate_change %>% select("Year", "CarbonDioxide_avg")
plot_ly(carb, x = ~Year, y = ~CarbonDioxide_avg, x.format= "%Y")  %>%  add_lines(y = ~CarbonDioxide_avg) %>% 
  layout(xaxis = list(title = "Year"),
         yaxis = list(title = "CO2 (parts per million)"),
         title = "Fig2 : The anual average of CO2 mole fraction between 1958-2016")

- It is illustrated in the above Figure 2 that the release of CO2 is going up sharly from 1958 to 2016 and it may keep rising in next few years.

plot_ly(climate_change, x = ~CarbonDioxide_avg, y = ~Global_Temperature_avg, type = 'scatter') %>% 
  layout(xaxis = list(title= "CO2 (parts per million)"),
         yaxis = list(title = "The change of global surface temperature (C)"),
         title = "Fig 3: The relationship between Global Temperature and CO2")

- To sum up, both CO2 release and global temperature has jumped up from 1958 to 2016. It likely seems that there is a relationship between CO2 and global temperature. Can we use CO2 to predict the change of global temperature in next few years ?

Hypothesis Testing

model <- lm(Global_Temperature_avg ~ CarbonDioxide_avg, data = climate_change)
model %>% summary()
## 
## Call:
## lm(formula = Global_Temperature_avg ~ CarbonDioxide_avg, data = climate_change)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.20603 -0.06850 -0.01029  0.07641  0.18567 
## 
## Coefficients:
##                     Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       -3.3364046  0.1659795  -20.10   <2e-16 ***
## CarbonDioxide_avg  0.0103374  0.0004703   21.98   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.09447 on 57 degrees of freedom
## Multiple R-squared:  0.8945, Adjusted R-squared:  0.8926 
## F-statistic: 483.1 on 1 and 57 DF,  p-value: < 2.2e-16

Hypthesis Testing Cont .

plot(model)

- Residual vs Fitted : The trend line seems to flat
- Normal Q-Q plot : the model seems to follow a normal distribution, except in the extreme tails

Intepreting

model %>% summary()
## 
## Call:
## lm(formula = Global_Temperature_avg ~ CarbonDioxide_avg, data = climate_change)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.20603 -0.06850 -0.01029  0.07641  0.18567 
## 
## Coefficients:
##                     Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       -3.3364046  0.1659795  -20.10   <2e-16 ***
## CarbonDioxide_avg  0.0103374  0.0004703   21.98   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.09447 on 57 degrees of freedom
## Multiple R-squared:  0.8945, Adjusted R-squared:  0.8926 
## F-statistic: 483.1 on 1 and 57 DF,  p-value: < 2.2e-16
model %>% confint()
##                          2.5 %      97.5 %
## (Intercept)       -3.668772837 -3.00403629
## CarbonDioxide_avg  0.009395619  0.01127923
cor(climate_change$Global_Temperature_avg, climate_change$CarbonDioxide_avg, use="complete.obs")
## [1] 0.9457604

Discussion

References