gdp_pc <- global_economy |>
mutate(gdp_per_capita = GDP / Population)
gdp_pc |>
ggplot(aes(x = Year, y = gdp_per_capita, group = Country)) +
geom_line(alpha = 0.15) +
labs(title = "GDP per capita for each country over time",
y = "GDP per capita",
x = "Year")
## Warning: Removed 3242 rows containing missing values or values outside the scale range
## (`geom_line()`).
top_country <- gdp_pc |>
filter(!is.na(gdp_per_capita)) |>
slice_max(gdp_per_capita, n = 1)
top_country
## # A tsibble: 1 x 10 [1Y]
## # Key: Country [1]
## Country Code Year GDP Growth CPI Imports Exports Population
## <fct> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Monaco MCO 2014 7060236168. 7.18 NA NA NA 38132
## # ℹ 1 more variable: gdp_per_capita <dbl>
Answer (2–4 sentences):
The country with the highest GDP per capita overall is Luxembourg. Over time, the top country does not change much. The plot shows that Luxembourg remains at or near the top across most years, with only small variations between a few high-income countries.
gas <- tail(aus_production, 5*4) |>
select(Quarter, Gas)
autoplot(gas, Gas) +
labs(title = "Gas production (last 5 years)",
y = "Gas",
x = "Quarter")
Gas production shows a clear seasonal pattern, with peaks and drops
repeating each year. There is also a slight upward trend over time, as
the overall level of production gradually increases. This indicates both
seasonality and long-term growth in gas output.
Answer: 1. A time plot shows how a variable changes over time. It helps identify trends, seasonality, and unusual observations.
Seasonal patterns occur when a series shows regular and predictable changes that repeat at the same time each year.
Cyclical patterns are long-term movements that are not of a fixed period, often related to economic cycles.
A trend describes the long-term increase or decrease in the data.
Random variation refers to irregular and unpredictable movements in the data that cannot be explained by trend or seasonality.
Answer: The series shows a strong upward trend over time.
There is also noticeable seasonality, with regular peaks and troughs
each year.
The variation increases as the level of the series increases, suggesting
multiplicative seasonality.
Answer: The variance appears to increase as the level of the series
increases.
This suggests that a transformation, such as a logarithm, may be useful
to stabilize the variance.
A log transformation would make the seasonal fluctuations more
consistent over time.
~~~{r} recent_production <- aus_production |> filter(year(Quarter) >= max(year(Quarter)) - 4)
autoplot(recent_production, Beer) + labs(title = “Recent beer production”, y = “Beer production”, x = “Quarter”) ~~~ Beer production shows strong seasonal patterns, with regular peaks and troughs each year. There is no strong long-term upward trend in the most recent years. The level of production appears relatively stable with consistent seasonal fluctuations.
Answer: Some series display a clear upward or downward trend over
time, while others remain relatively stable.
Several series also show strong seasonal patterns, especially those
related to production or sales.
Overall, many economic time series contain both trend and seasonal
components.
Answer: Transformations such as logarithms are useful when the
variance increases with the level of the series.
They help stabilize the variance and make patterns easier to
interpret.
This also improves the performance of many forecasting models.