1. Consider the GDP information in global_economy. Plot the GDP per capita for each country over time. Which country has the highest GDP per capita? How has this changed over time?
global_economy %>%
  tsibble(key = Code, index = Year)%>%
  autoplot(GDP/Population, show.legend =  FALSE) +
  labs(title= "GDP per capita",
       y = "$US")
## Warning: Removed 3242 row(s) containing missing values (geom_path).

From the plot, we can see that most of GDP per capita has increased over time. It seems that Luxembourg had the highest GDP per capita in 2014

global_economy %>%
  mutate(GDPperc = GDP/Population) %>%
  group_by(Country) %>%
   mutate(max1 = max(GDPperc))%>%
  filter(GDPperc == max1)%>%
 select(Country, Year, GDPperc)%>%
  arrange(desc(GDPperc))
## # A tsibble: 124 x 3 [1Y]
## # Key:       Country [124]
## # Groups:    Country [124]
##    Country        Year GDPperc
##    <fct>         <dbl>   <dbl>
##  1 Luxembourg     2014 119225.
##  2 Norway         2013 103059.
##  3 Iceland        2017  70057.
##  4 Ireland        2017  69331.
##  5 Australia      2013  67990.
##  6 Denmark        2008  64322.
##  7 Sweden         2013  60283.
##  8 United States  2017  59532.
##  9 North America  2017  58070.
## 10 Singapore      2017  57714.
## # ... with 114 more rows
  1. For each of the following series, make a graph of the data. If transforming seems appropriate, do so and describe the effect.

a United States GDP from global_economy.

global_economy %>%
  filter(Country == "United States") %>%
  autoplot(GDP)+
  labs(title = "United States GDP", y = "$US")

b Slaughter of Victorian “Bulls, bullocks and steers” in aus_livestock.

aus_livestock %>%
  filter(Animal == "Bulls, bullocks and steers",
         State == "Victoria")%>%
  autoplot(Count)+
  labs(title = "Slaughter of Victorian “Bulls, bullocks and steers”")

c Victorian Electricity Demand from vic_elec.

vic_elec %>%
  autoplot(Demand)+
  labs(title = "Victorian Electricity Demand",
       y = "Demand")

d Gas production from aus_production.

aus_production %>%
  autoplot(Gas)+
  labs(title = "Gas production")

3.Why is a Box-Cox transformation unhelpful for the canadian_gas data?

canadian_gas %>%
  autoplot(Volume)+
  labs(title = "Canadian Gas Production",
       y = "Monthly Canadian Gas Production (billions of cubic meter)")+
  theme_replace()

lambda_cangas <- canadian_gas %>%
                  features(Volume, features = guerrero) %>%
                  pull(lambda_guerrero)
canadian_gas %>%
  autoplot(box_cox(Volume, lambda = lambda_cangas))+
  labs(title = latex2exp::TeX(paste0(
         "Box Cox Transformation of Canadian Gas Production with $\\lambda$ = ",
         round(lambda_cangas,2))))

The box-cox transformation produces similar results to the original, as shown by the comparison of both autoplots; the transformation does not provide stationarity to time series.

4.What Box-Cox transformation would you select for your retail data (from Exercise 8 in Section 2.10)?

set.seed(666)
myseries <- aus_retail %>%
  filter(`Series ID` == sample(aus_retail$`Series ID`,1))

myseries %>%
  autoplot(Turnover)+
  labs(title = "Australian Retail Trade Turnover")

5. For the following series, find an appropriate Box-Cox transformation in order to stabilise the variance. Tobacco from aus_production,

lambda_tobacco <- aus_production %>%
                   features(Tobacco, features = guerrero) %>%
                   pull(lambda_guerrero)
aus_production %>%
  autoplot(box_cox(Tobacco, lambda_tobacco)) +
  labs(y = "",
       title = latex2exp::TeX(paste0(
         "Transformed gas production with $\\lambda$ = ",
         round(lambda_tobacco,2))))
## Warning: Removed 24 row(s) containing missing values (geom_path).

Economy class passengers between Melbourne and Sydney from ansett, and

lambda_class <- ansett %>%
                 filter(Class == "Economy",
                        Airports == "MEL-SYD")%>%
                 features(Passengers, features = guerrero) %>%
                 pull(lambda_guerrero)
ansett %>%
  filter(Class == "Economy",
         Airports == "MEL-SYD")%>%
  mutate(Passengers = Passengers/1000) %>%
  autoplot(box_cox(Passengers, lambda = lambda_class)) +
  labs(y = "Passengers ('000)",
       title = latex2exp::TeX(paste0(
         "Transformed Airlines Economy Class with $\\lambda$ = ",
         round(lambda_class,2))),
       subtitle = "Melbourne-Sydney")

Pedestrian counts at Southern Cross Station from pedestrian.

lambda_count <- pedestrian %>%
                filter(Sensor == "Southern Cross Station") %>%
                 features(Count, features = guerrero) %>%
                 pull(lambda_guerrero)
pedestrian %>%
  filter(Sensor == "Southern Cross Station") %>%
  autoplot(box_cox(Count,lambda_count))+
  labs(y = "",
       title = latex2exp::TeX(paste0(
         "Transformed Pedestrian Counts at Southern Cross Station with $\\lambda$ = ",
         round(lambda_count,2))))

7. Consider the last five years of the Gas data from aus_production.

gas <- tail(aus_production, 5*4) %>% select(Gas)
  1. Plot the time series. Can you identify seasonal fluctuations and/or a trend-cycle?
gas %>%
  autoplot()+
  labs(title = "Gas Data")
## Plot variable not specified, automatically selected `.vars = Gas`

seasonality with a frequency of 1 year and a trend-cycle that shows an increasing trend. b. Use classical_decomposition with type=multiplicative to calculate the trend-cycle and seasonal indices.

gas %>%
  model(classical_decomposition(Gas,type = "multiplicative")) %>%
  components() %>%
  autoplot() + 
  ggtitle("Gas Data")
## Warning: Removed 2 row(s) containing missing values (geom_path).

c. Do the results support the graphical interpretation from part a? The results support the graphical interpretation from part a, which was a seasonality of frequency 1 year and an increasing trend. Also classical multiplicative decomposition relies on moving averages, there is no data at the beginning and end of the trend-cycle. d. Compute and plot the seasonally adjusted data.

  1. Change one observation to be an outlier (e.g., add 300 to one observation), and recompute the seasonally adjusted data. What is the effect of the outlier?

  2. Does it make any difference if the outlier is near the end rather than in the middle of the time series?

  1. Recall your retail time series data (from Exercise 8 in Section 2.10). Decompose the series using X-11. Does it reveal any outliers, or unusual features that you had not noticed previously?
myseries %>%
  model(classical_decomposition(Turnover,type = "multiplicative")) %>%
  components() %>%
  autoplot() 
## Warning: Removed 6 row(s) containing missing values (geom_path).

myseries %>%
  model(x11 = X_13ARIMA_SEATS(Turnover ~ x11())) %>%
  components() %>%
  autoplot()

Compare both graphs, the X-11 trend-cycle has captured the sudden decrease in the 2000-2010 9. Figures 3.19 and 3.20 show the result of decomposing the number of persons in the civilian labour force in Australia each month from February 1978 to August 1995.

  1. Write about 3–5 sentences describing the results of the decomposition. Pay particular attention to the scales of the graphs in making your interpretation.

Isolating the trend component from the seasonal component shows that the trend has increased through the most of the time frame, with a few stationary periods occurring in the early 90s. The monthly breakdown of the seasonal component shows that a few months show greater velocities in their variations than other months.There were significant recessions in 1991 and 1992, which were reflected in seasonally adjusted results.

  1. Is the recession of 1991/1992 visible in the estimated components? Yes, we see a decrease in employment during 1991/1992 that is not explained by seasonality or the positive trend