if (!require("fpp2")) install.packages("fpp2")

Week 1 HW Problems

2.1

Use the help function to explore what the series gold, woolyrnq and gas represent.

A. Use autoplot() to plot each of these in separate plots:

B. What is the frequency of each series? Hint: apply the frequency() function.

C. Use which.max() to spot the outlier in the gold series. Which observation was it?

Gold

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##   285.0   337.7   403.2   392.5   443.7   593.7      34

What is the Frequency of Gold?

## [1] "The Frequency of Gold is 1"

Where is the outlier?

## [1] "Outlier: 770"

Wool

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    3324    4882    5466    5658    6646    7819

## [1] "The Frequency of Woolyrnq is 4"

Gas

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1646    2675   16788   21415   38629   66600

## [1] "The Frequency of Gas is 12"

2.2

Down the file tute1.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.

A. You can read the data into R with the following script:

B. Convert the data to time series.

C. Construct time series plots of each of the three series.

2.3

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.

A. You can read the data into R with the following script:

B. Select one of the time series as follows (but replace the column name with your own chosen column):

C. 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?

The seasonal plot actually shows a the consumer spends between from October and December.

The sub series plot shows mean value in timeseries. Mean value also confirmed that October to December customer spend more.

There is tread in plot that consumer buy more stuff in December than November

2.6

Use the following graphics functions: 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?