Time series data

The planet isn't going anywhere. We are! We're goin' away.
- Philosopher and comedian, George Carlin

Climate change is happening. It always has and will, but the big question, at least from a political and economic standpoint, is the climate change man-made? I'll use this chapter to put econometric time series modeling to the test to try and learn whether carbon emissions cause, statistically speaking, climate change and, in particular, rising temperatures. Personally, I'd like to take a neutral stance on the issue, always keeping in mind the wise tenets that Mr. Carlin left for us in his teachings on the subject.

The first order of business is to find and gather the data. For temperature, I chose the HadCRUT4 annual median temperature time series, which is probably the gold standard. This data is compiled by a cooperative effort of the Climate Research Unit of the University of East Anglia and the Hadley Centre at the UK Meteorological Office. A full discussion of how the data is compiled and modeled is available at http://www.metoffice.gov.uk/hadobs/index.html.

The data that we'll use is provided as an annual anomaly, which is calculated as the difference of the median annual surface temperature for a given time period versus the average of the reference years (1961-1990). The annual surface temperature is an ensemble of the temperatures collected globally and blended from the CRUTEM4 surface air temperature and HadSST3 sea-surface datasets. Skeptics have attacked biased and unreliable: http://www.telegraph.co.uk/comment/11561629/Top-scientists-start-to-examine-fiddled-global-warming-figures.html. This is way outside of our scope of effort here, so we must accept and utilize this data as is, but I find it amusing nonetheless. I've pulled the data from 1919 through 2013 to match our CO2 data.

Global CO2 emission estimates can be found at the Carbon Dioxide Information Analysis Center (CDIAC) of the US Department of Energy at the following website: http://cdiac.ornl.gov/.

I've placed the data in a .csv file (climate.csv) for you to download and store in your working directory: https://github.com/PacktPublishing/Advanced-Machine-Learning-with-R/blob/master/Data/climate.csv.

Let's install libraries as needed, load the data, and examine the structure:

> library(magrittr)

> install.packages("tidyverse")

> install.packages("ggplot2")

> install.packages("ggthemes")

> install.packages("tseries")

> climate <- readr::read_csv("climate.csv")

> str(climate)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 95 obs. of 3 variables:
$ Year: int 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 ...
$ CO2 : int 806 932 803 845 970 963 975 983 1062 1065 ...
$ Temp: num -0.272 -0.241 -0.187 -0.301 -0.272 -0.292 -0.214 -0.105 -0.208 -0.206 ...

We'll put this in a time series structure, specifying the start and end years:

> climate_ts <- ts(climate[, 2:3],
start = 1919,
end = 2013)

With our data loaded and put in time series structures, we can now begin to understand and further prepare it for analysis.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.134.151