---
title: "Time Series data and autoplot()"
author: "Prof. Eric A. Suess"
date: "1/23/2023"
format: html
---

Today we are going to take a look at a number of the time series dataset, tibbles, that are used in the [fpp3](https://otexts.com/fpp3/) book.

The first datast to look at is the **beer** data.

```{r}
library(fpp3)
```

See the information about the *tsibble* package and find the description of the **aus_retail** dataset.

```{r}
aus_retail

class(aus_retail)
```

Note that the dataset is not in the R Environment.  This makes it hard to see what the dataset contains.  To load the dataset we use the *data()* R function.  

```{r}
data(aus_production)

head(aus_production)
```

Open the dataset, does it look like there is more than on time series contained in the dataset?

When the dataset is piped into autoplot, the first time series column is plotted.

```{r}
aus_production %>% autoplot()
```

```{r}
aus_production %>% autoplot(Beer)
```

Why does this look different from the picture in Section 4?

```{r}
aus_prod_2000 <- aus_production %>% select(Quarter, Beer) %>% 
  filter(Quarter >= yearquarter("2000 Q1"))

aus_prod_2000
```

Now try plotting.

```{r}
aus_prod_2000 %>% autoplot()
```
 
 Try this for each of the time series.
 
```{r}
aus_prod_2000 <- aus_production %>% select(Quarter, Bricks) %>% 
  filter(Quarter >= yearquarter("2000 Q1"))

aus_prod_2000 %>% autoplot()
``` 
 
 In Section 1.7 
 
 For Homework 1 you need to work with the following datasets from the *tsibble* R package.
 
```{r}
gafa_stock
```

```{r}
PBS
```

```{r}
vic_elec
```

```{r}
pelt
```

```{r}
pelt %>% autoplot()
```

 
 There is a clear pattern in the pelt time  time series data.  We will measure the Autocorrelation in time series data using the ACF function.
 
```{r}
ACF(pelt)
```
 
And we can plot the ACF.  Can you see the positive and negative correlations in the time series?
 
```{r}
ACF(pelt) %>% autoplot()
```
 
 
 