Seasonal plots
Along with time plots, there are other useful ways of plotting data to emphasize seasonal patterns and show changes in these patterns over time.
- A seasonal plot is similar to a time plot except that the data are plotted against the individual “seasons” in which the data were observed. You can create one using the
ggseasonplot()function the same way you do withautoplot(). - An interesting variant of a season plot uses polar coordinates, where the time axis is circular rather than horizontal; to make one, simply add a
polarargument and set it toTRUE. - A subseries plot comprises mini time plots for each season. Here, the mean for each season is shown as a blue horizontal line.
One way of splitting a time series is by using the window() function, which extracts a subset from the object x observed between the times start and end.
> window(x, start = NULL, end = NULL)
In this exercise, you will load the fpp2 package and use two of its datasets:
a10contains monthly sales volumes for anti-diabetic drugs in Australia. In the plots, can you see which month has the highest sales volume each year? What is unusual about the results in March and April 2008?ausbeerwhich contains quarterly beer production for Australia. What is happening to the beer production in Quarter 4?
These examples will help you to visualize these plots and understand how they can be useful.
Cet exercice fait partie du cours
Forecasting in R
Instructions
- Use
library()to load thefpp2package. - Use
autoplot()andggseasonplot()to produce plots of thea10data. - Use the
ggseasonplot()function and itspolarargument to produce a polar coordinate plot for thea10data. - Use the
window()function to consider only theausbeerdata starting from 1992. - Finally, use
autoplot()andggsubseriesplot()to produce plots of thebeerseries.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Load the fpp2 package
___
# Create plots of the a10 data
___
___
# Produce a polar coordinate season plot for the a10 data
ggseasonplot(___, polar = ___)
# Restrict the ausbeer data to start in 1992
beer <- ___(___, ___)
# Make plots of the beer data
___
___