?gold
?woolyrnq
?gas
autoplot(gold)
autoplot(woolyrnq)
autoplot(gas)
frequency(gold)
## [1] 1
frequency(woolyrnq)
## [1] 4
frequency(gas)
## [1] 12
which.max(gold)
## [1] 770
tute1 <- read.csv('https://otexts.com/fpp2/extrafiles/tute1.csv', header = TRUE)
mytimeseries <- ts(tute1[,-1], start=1981, frequency = 4)
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.
myts <- ts(retaildata[,'A3349399C'], frequency = 12, start = c(1982,4))
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.
?hsales
autoplot(hsales)
ggseasonplot(hsales)
ggsubseriesplot(hsales)
gglagplot(hsales)
ggAcf(hsales)
?usdeaths
autoplot(usdeaths)
ggseasonplot(usdeaths)
ggsubseriesplot(usdeaths)
gglagplot(usdeaths)
ggAcf(usdeaths)
####Seasonality: There seems to be a strong correlation to the summer months with accidental deaths in the USA. ####Cyclicity: There does not appear to be a cyclicity to this data ####Trends: The trend here is that more people are accidently die in the summertime - could be that there are more outside activities that result in death during that time.
?bricksq
autoplot(bricksq)
ggseasonplot(bricksq)
ggsubseriesplot(bricksq)
gglagplot(bricksq)
ggAcf(bricksq)
####Seasonality: I don’t see any seasonal trends within the data ####Cyclicity: There is cyclicity. It looks like towards the end of each quater there is an increased production in bricks ####Trends: There seems to be an overall decrease in brick production as the years pass
?sunspotarea
autoplot(sunspotarea)
#ggseasonplot(sunspotarea)
#ggsubseriesplot(sunspotarea)
gglagplot(sunspotarea)
ggAcf(sunspotarea)
####Seasonality: The data is not seasonal and therefore cannot be graphed ####Cyclicity: You can see that is an increase in sunspot around every 10 years - but hard to pull out more learnings that that.
?gasoline
autoplot(gasoline)
ggseasonplot(gasoline)
#ggsubseriesplot(gasoline)
gglagplot(gasoline)
ggAcf(gasoline)
####Seasonality: The ACF chart shows some scalloping - which suggests that there is seasonality to gasoline production supplied. ####Cyclicity: ####Trends: Looks like there is less gasoline used in february. and that gas supplies increase during the summer weeks. ####Learnings