str(gold)
## Time-Series [1:1108] from 1 to 1108: 306 300 303 297 304 ...
str(woolyrnq)
## Time-Series [1:119] from 1965 to 1994: 6172 6709 6633 6660 6786 ...
str(gas)
## Time-Series [1:476] from 1956 to 1996: 1709 1646 1794 1878 2173 ...
autoplot(gold)
autoplot(woolyrnq)
autoplot(gas)
writeLines("")
cat("Gold Frequency: ", frequency(gold))
## Gold Frequency: 1
cat("Woolyrnq Frequency: ", frequency(woolyrnq))
## Woolyrnq Frequency: 4
cat("Gas Frequency: ", frequency(gas))
## Gas Frequency: 12
cat("When gold got maximum value? ", which.max(gold))
## When gold got maximum value? 770
cat("What was the gold's maximum value? ", gold[which.max(gold)])
## What was the gold's maximum value? 593.7
 tute1 <- read.csv("tute1.csv", header=TRUE)
 View(tute1)
tute1 <- read.csv("tute1.csv", header=TRUE)
View(tute1)
 mytimeseries <- ts(tute1[,-1], start=1981, frequency=4)
(The [,-1] removes the first column which contains the quarters as we don’t need them now.)
mytimeseries <- ts(tute1[,-1], start=1981, frequency=4)
 autoplot(mytimeseries, facets=TRUE)
Check what happens when you don’t include facets=TRUE.
autoplot(mytimeseries, facets=TRUE)
autoplot(mytimeseries)
 retaildata <- readxl::read_excel("retail.xlsx", skip=1)
The second argument (skip=1) is required because the Excel sheet has two header rows.
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[,"A3349873A"], frequency=12, start=c(1982,4))
myts <- ts(retaildata[,"A3349873A"], frequency=12, start=c(1982,4))
 autoplot(), ggseasonplot(), ggsubseriesplot(), gglagplot(), ggAcf()
Can you spot any seasonality, cyclicity and trend? What do you learn about the series?
autoplot(myts)
ggseasonplot(myts)
ggsubseriesplot(myts)
gglagplot(myts, lags = 12)
ggAcf(myts)
cat("can see seasonality and trend of the data")
## can see seasonality and trend of the data
autoplot, ggseasonplot, ggsubseriesplot, gglagplot, ggAcf
and explore features from the following time series: hsales, usdeaths, bricksq, sunspotarea, gasoline
.autoplot(hsales)
ggseasonplot(hsales)
ggsubseriesplot(hsales)
gglagplot(hsales)
ggAcf(hsales, lag.max = 400)
cat("can spot seasonality and cyclicity. The cycle period is about 4 years(100 months)")
## can spot seasonality and cyclicity. The cycle period is about 4 years(100 months)
autoplot(usdeaths)
ggseasonplot(usdeaths)
ggsubseriesplot(usdeaths)
gglagplot(usdeaths)
ggAcf(usdeaths, lag.max = 60)
cat("can spot seasonality")
## can spot seasonality
autoplot(bricksq)
ggseasonplot(bricksq)
ggsubseriesplot(bricksq)
gglagplot(bricksq)
ggAcf(bricksq, lag.max = 200)
cat("can spot little seasonality and strong trend")
## can spot little seasonality and strong trend
autoplot(sunspotarea)
# ggseasonplot(sunspotarea)
# ggsubseriesplot(sunspotarea)
print("For ggseasonplot, not seasonal | can't draw it. For ggsubseriesplot, not seasonal | useless to draw it")
## [1] "For ggseasonplot, not seasonal | can't draw it. For ggsubseriesplot, not seasonal | useless to draw it"
gglagplot(sunspotarea)
ggAcf(sunspotarea, lag.max = 50)
cat("can spot strong cyclicity")
## can spot strong cyclicity
autoplot(gasoline)
ggseasonplot(gasoline)
# ggsubseriesplot(gasoline)
print("The number of weeks is 52 and it looked like it is too much for subseriesplot")
## [1] "The number of weeks is 52 and it looked like it is too much for subseriesplot"
gglagplot(gasoline)
ggAcf(gasoline, lag.max = 1000)
cat("can spot seasonality and trend")
## can spot seasonality and trend