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)
cat("Gold Frequency is: ", frequency(gold))
## Gold Frequency is: 1
cat("woolyrnq Frequency is: ", frequency(woolyrnq))
## woolyrnq Frequency is: 4
cat("gas Frequency is: ", frequency(gas))
## gas Frequency is: 12
cat("When is the maximum value for gold? ",which.max(gold))
## When is the maximum value for gold? 770
cat("What is the maximum value for gold? ",gold[which.max(gold)])
## What is the maximum value for gold? 593.7
Download the file 1.csv from the book website, open it in Excel (or some other spreadsheet application), and review its contents. You should find four columns of information. Columns B through D each contain a quarterly series, labelled Sales, AdBudget and GDP. Sales contains the quarterly sales for a small company over the period 1981-2005. AdBudget is the advertising budget and GDP is the gross domestic product. All series have been adjusted for inflation.
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.)
autoplot(mytimeseries, facets=TRUE)
Check what happens when you don’t include facets=TRUE.
autoplot(mytimeseries)
Download some monthly Australian retail data from the book website. These represent retail sales in various categories for different Australian states, and are stored in a MS-Excel file.
retaildata <- readxl::read_excel("retail.xlsx", skip=1)
The second argument (skip=1) is required because the Excel sheet has two header rows.
Select one of the time series as follows (but replace the column name with your own chosen column):
myts <- ts(retaildata[,"A3349640L"],
frequency=12, start=c(1982,4))
Explore your chosen retail time series using the following functions: autoplot(), ggseasonplot(), ggsubseriesplot(), gglagplot(), ggAcf()
Can you spot any seasonality, cyclicity and trend? What do you learn about the series?
Data generated on Turnover; Victoria;Cafes, restaurants and catering services
autoplot(myts)
ggseasonplot(myts)
# too many observations to clearly read the non polar graph
ggseasonplot(myts, polar=TRUE)
ggsubseriesplot(myts)
gglagplot(myts)
ggAcf(myts)
autoplot(), ggseasonplot(), ggsubseriesplot(), gglagplot(), ggAcf() and explore features from the following time series: hsales, usdeaths, bricksq, sunspotarea, gasoline.
Can you spot any seasonality, cyclicity and trend?
What do you learn about the series?
autoplot(hsales)
ggseasonplot(hsales)
ggseasonplot(hsales, polar = TRUE)
ggsubseriesplot(hsales)
gglagplot(hsales)
ggAcf(hsales)
autoplot(usdeaths)
ggseasonplot(usdeaths)
ggseasonplot(usdeaths, polar = TRUE)
ggsubseriesplot(usdeaths)
gglagplot(usdeaths)
ggAcf(usdeaths)
autoplot(bricksq)
ggseasonplot(bricksq)
# too many observations to clearly read the non polar graph
ggseasonplot(bricksq, polar=TRUE)
ggsubseriesplot(bricksq)
gglagplot(bricksq)
ggAcf(bricksq)
autoplot(sunspotarea)
#ggseasonplot(sunspotarea)
#ggsubseriesplot(sunspotarea)
gglagplot(sunspotarea)
ggAcf(sunspotarea)
autoplot(gasoline)
ggseasonplot(gasoline)
# too many observations to clearly read the non polar graph
ggseasonplot(gasoline, polar = TRUE)
#ggsubseriesplot(gasoline)
gglagplot(gasoline)
ggAcf(gasoline)