Unit 2b TS Decomposition
Unit 2b TS Decomposition
2
Time series decomposition
3
Time series decomposition
4
Transformations and adjustments
5
Population Adjustement/Per capita adjustments
global_economy %>%
filter(Country == "Australia") %>%
autoplot(GDP)
1.5e+12
1.0e+12
GDP
5.0e+11
0.0e+00
1960 1980 2000
Year [1Y]
6
Per capita adjustments
global_economy %>%
filter(Country == "Australia") %>%
autoplot(GDP / Population)
60000
GDP/Population
40000
20000
0
1960 1980 2000
Year [1Y]
7
Exercise
8
Inflation adjustments
9
Inflation adjustments
4000
Turnover
3000
2000
$AU
5000
Adjusted_turnover
4500
4000
3500
3000
11
Mathematical transformations
10000
Turnover ($AUD)
5000
13
Mathematical transformations
100
Square root turnover
75
50
20
Cube root turnover
15
10
1990 Jan 2000 Jan 2010 Jan 2020 Jan
Month [1M]
15
Mathematical transformations
9.5
9.0
Log turnover
8.5
8.0
7.5
7.0
1990 Jan 2000 Jan 2010 Jan 2020 Jan
Month [1M]
16
Mathematical transformations
−0.00025
Inverse turnover
−0.00050
−0.00075
18
Box-Cox transformations
Box−Cox transformed food retailing turnover (lambda = 1)
12500
10000
7500
Turnover
5000
2500
19
Box-Cox transformations
food %>%
features(Turnover, features = guerrero)
## # A tibble: 1 x 1
## lambda_guerrero
## <dbl>
## 1 0.0895
12
Box−Cox transformed turnover
11
10
22
Time series components
23
Time series patterns
Recall
24
Time series decomposition
yt = f (St , Tt , Rt )
25
Time series decomposition
us_retail_employment %>%
autoplot(Employed) +
labs(y = "Persons (thousands)",
title = "Total employment in US retail")
16000
Persons (thousands)
15000
14000
13000
28
US Retail Employment
us_retail_employment %>%
model(stl = STL(Employed))
## # A mable: 1 x 1
## stl
## <model>
## 1 <STL>
29
US Retail Employment
us_retail_employment %>%
autoplot(Employed, color='gray') +
autolayer(components(dcmp), trend, color='#D55E00') +
labs(y = "Persons (thousands)",
title = "Total employment in US retail")
16000
Persons (thousands)
15000
14000
13000
STL decomposition
Employed = trend + season_year + remainder
16000
Employed
15000
14000
13000
16000
15000
trend
14000
13000
season_year
500
250
0
−250
100
remainder
50
0
−50
−100
1990 Jan 2000 Jan 2010 Jan 2020 Jan
Month
32
season_year
−250
0
250
500
1990
2000
Jan
2010
2020
1990
2000
2010 Feb
2020
1990
2000
Mar
2010
2020
1990
2000
Apr
US Retail Employment
2010
2020
1990
2000
May
2010
2020
1990
2000
Jun
2010
2020
1990
Month
2000
Jul
2010
2020
1990
2000
Aug
2010
2020
1990
2000
Sep
2010
2020
components(dcmp) %>% gg_subseries(season_year)
1990
2000
Oct
2010
2020
1990
2000
Nov
2010
2020
1990
2000
Dec
2010
2020 stl
33
Seasonal adjustment
yt − St = Tt + Rt
34
US Retail Employment
us_retail_employment %>%
autoplot(Employed, color='gray') +
autolayer(components(dcmp), season_adjust, color='#0072B2') +
labs(y = "Persons (thousands)",
title = "Total employment in US retail")
16000
Persons (thousands)
15000
14000
13000
36
Classical Decomposition
1 ∑ k
T̂t = yt+j , where m = 2k + 1
m j=−k
37
Moving Average Smoothing
21
% of GDP
18
15
12
1960 1980 2000
Year [1Y]
39
Moving average smoothing
40
Moving average smoothing
21
% of GDP
18
15
12
1960 1980 2000
Year [1Y]
41
Moving average smoothing
21
% of GDP
18
15
12
1960 1980 2000
Year [1Y]
42
Exercise:
43
Next Lecture!
44