Homework Assigment 1

Exercise 2.1

?gold
?woolyrnq
?gas

a.

autoplot(gold)

autoplot(woolyrnq)

autoplot(gas)

b.

frequency(gold)
## [1] 1
frequency(woolyrnq)
## [1] 4
frequency(gas)
## [1] 12

c.

which.max(gold)
## [1] 770
observation 770

Exercise 2.2

a.

tute1 <- read.csv('https://otexts.com/fpp2/extrafiles/tute1.csv', header = TRUE)

b.

mytimeseries <- ts(tute1[,-1], start=1981, frequency = 4)

c.

autoplot(mytimeseries, facets = TRUE)

###Exercise 2.3 ####a.

retaildata <- readxl::read_excel('retail.xlsx', skip = 1)
## readxl works best with a newer version of the tibble package.
## You currently have tibble v1.4.2.
## Falling back to column name repair from tibble <= v1.4.2.
## Message displays once per session.

b.

myts <- ts(retaildata[,'A3349399C'], frequency = 12, start = c(1982,4))

c.

autoplot(myts)

The pattern is clear and increasing over time. The spike represents the holiday season and the subsequent fall probably has to do with people saving money post-holidays.

ggseasonplot(myts)

There is a clear jump in retail clothing sales in december. For the most part, there is a seasonal trend. I assume that the small increal in the month of May is due to a season change.

ggsubseriesplot(myts)

####This plot shows the mean of the seasonality over time. There is a slight varience in the mean between the first 11 months of the year, then a huge increase in the mean in december. The category is clothing: retail, so I assume that this is because of holiday shopping.

gglagplot(myts)

####The relationship is stronly positive in lag 1 and 12. The negative relationship can be seen in lags 4 and 16, which make sense quarterly.

ggAcf(myts)

####The scalloped shape of the ACF is due to the seasonality of the data. The data seems to spike every 12 months.

Exercise 2.6

?hsales
autoplot(hsales)

ggseasonplot(hsales)

ggsubseriesplot(hsales)

gglagplot(hsales)

ggAcf(hsales)

Seasonality: There is some seasonality with homes purchased in the Spring. There is a definite drop in home sales at the end of the year

Cyclicity: Since this data has approximately 23 years - we can see a rise in the mean in March and April and a decrease in November in December.