Chapter 2 Time Series

Reference : Statistical Inference via Data Science.

2.1 Needed Package

I recommend you to install tidyverse, a collection of packages for data science. To install and load the packages, type

2.3 Sample Moments

Note that \(E(X_t) = 0\), \(\gamma(0) = Var(X_t) = (1 + \theta^2)\sigma^2\) and \(\gamma(1) = Cov(X_t, X_{t-1}) = \theta \sigma^2\). We compute sample moments and compare them with theoretical moments.

## [1] 0.0002941528 0.0006930542 0.0007107480

2.4 ggplot2

ggplot2 is one the most widely used packages for data visualization. We already loaded this package by running library(tidyverse). In fact, we loaded all the following packages at once,

  • ggplot2, dplyr, tidyr, readr, purrr, tibble, strignr, and forcats packages.

If you don’t need other packages, type library(ggplot2).

2.4.1 The Grammar of Graphics

The gg in ggplot2 is an abbreviation for the grammar of graphics. According to Wickham (2016), the grammar tells us that a statistical graphic is a mapping from data to aesthetic attributes (colour, shape, size) of geometric objects (points, lines, bars). The plot may also contain statistical transformations of the data and is drawn on a specific coordinate system.