Fast computation of reconciled forecasts in hierarchical and grouped time series Total

advertisement
Rob J Hyndman
Fast computation of reconciled
forecasts in hierarchical and
grouped time series
Total
A
AX
AY
C
B
AZ
BX
BY
BZ
CX
CY
CZ
1
Outline
1
Optimally reconciled forecasts
2
Fast computation
3
hts package for R
4
References
Fast computation of reconciled forecasts
Optimally reconciled forecasts
2
Hierarchical data
Total
A
AX






Yt = 





AY
Yt
YA,t
YB,t
YC,t
YAX,t
YAY ,t
YAZ,t
YBX,t
YBY ,t
YBZ,t
YCX,t
YCY ,t
YCZ,t

C
B
AZ
BX
1
1
0
0
1
0
0
0
0
0
0
0
0
 
 
 
 
 
=
 
 
 
 
 
1
1
0
0
0
1
0
0
0
0
0
0
0
1
1
0
0
0
0
1
0
0
0
0
0
0
1
0
1
0
0
0
0
1
0
0
0
0
0
|
Fast computation of reconciled forecasts
BY
1
0
1
0
0
0
0
0
1
0
0
0
0
{z
S
1
0
1
0
0
0
0
0
0
1
0
0
0
CX
BZ
1
0
0
1
0
0
0
0
0
0
1
0
0
1
0
0
1
0
0
0
0
0
0
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
1
CY
CZ

YAX,t 
 YAY,t
Y 
 AZ,t 
YBX,t 
YBY,t 
YBZ,t 
Y 
 CX,t
 YCY,t
 YCZ,t
| {z }
Bt
}
Optimally reconciled forecasts
3
Hierarchical data
Total
A
AX






Yt = 





AY
Yt
YA,t
YB,t
YC,t
YAX,t
YAY ,t
YAZ,t
YBX,t
YBY ,t
YBZ,t
YCX,t
YCY ,t
YCZ,t

C
B
AZ
BX
1
1
0
0
1
0
0
0
0
0
0
0
0
 
 
 
 
 
=
 
 
 
 
 
1
1
0
0
0
1
0
0
0
0
0
0
0
1
1
0
0
0
0
1
0
0
0
0
0
0
1
0
1
0
0
0
0
1
0
0
0
0
0
|
Fast computation of reconciled forecasts
BY
1
0
1
0
0
0
0
0
1
0
0
0
0
{z
S
1
0
1
0
0
0
0
0
0
1
0
0
0
CX
BZ
1
0
0
1
0
0
0
0
0
0
1
0
0
1
0
0
1
0
0
0
0
0
0
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
1
CY
CZ

YAX,t 
 YAY,t
Y 
 AZ,t 
YBX,t 
YBY,t 
YBZ,t 
Y 
 CX,t
 YCY,t
 YCZ,t
| {z }
Bt
}
Optimally reconciled forecasts
3
Hierarchical data
Total
A
AX






Yt = 





AY
Yt
YA,t
YB,t
YC,t
YAX,t
YAY ,t
YAZ,t
YBX,t
YBY ,t
YBZ,t
YCX,t
YCY ,t
YCZ,t

C
B
AZ
BX
1
1
0
0
1
0
0
0
0
0
0
0
0
 
 
 
 
 
=
 
 
 
 
 
1
1
0
0
0
1
0
0
0
0
0
0
0
1
1
0
0
0
0
1
0
0
0
0
0
0
1
0
1
0
0
0
0
1
0
0
0
0
0
|
Fast computation of reconciled forecasts
BY
1
0
1
0
0
0
0
0
1
0
0
0
0
{z
S
1
0
1
0
0
0
0
0
0
1
0
0
0
CX
BZ
1
0
0
1
0
0
0
0
0
0
1
0
0
1
0
0
1
0
0
0
0
0
0
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
1
CY

YAX,t 
 YAY,t
Y 
 AZ,t 
YBX,t 
YBY,t 
YBZ,t 
Y 
 CX,t
 YCY,t
 YCZ,t
| {z }
Bt
CZ
Yt = SBt
}
Optimally reconciled forecasts
3
Grouped data

Yt =

Yt
Y
 A,t 
 YB,t 
 YC,t 


 YX,t 
 YY ,t 


 YZ,t 
YAX,t 


YAY ,t 
YAZ,t 


YBX,t 
YBY ,t 


YBZ,t 
YCX,t 


YCY ,t
YCZ,t

=
1
1
0
0

1
0

0
1

0
0

0
0

0
0

0
0
1
1
0
0
0
1
0
0
1
0
0
0
0
0
0
0
AX
AY
AZ
A
BX
BY
BZ
B
CX
CY
CZ
C
X
Y
Z
Total

1
1
0
0
0
0
1
0
0
1
0
0
0
0
0
0
1
0
1
0
1
0
0
0
0
0
1
0
0
0
0
0
Fast computation of reconciled forecasts
|
1
0
1
0
0
1
0
0
0
0
0
1
0
0
0
0
{z
1
0
1
0
0
0
1
0
0
0
0
0
1
0
0
0
1
0
0
1
1
0
0
0
0
0
0
0
0
1
0
0
1
0
0
1
0
1
0
0
0
0
0
0
0
0
1
0
1
0

0 
YAX,t
1

0 YAY ,t 


0
 YAZ,t 

1 
YBX,t 


0 
Y 
0  BY ,t 

0 YBZ,t 


0 YCX,t 


0  Y
CY ,t
0
 YCZ,t
0
| {z }
0
Bt
1
Optimally reconciled forecasts
}
4
Grouped data

Yt =

Yt
Y
 A,t 
 YB,t 
 YC,t 


 YX,t 
 YY ,t 


 YZ,t 
YAX,t 


YAY ,t 
YAZ,t 


YBX,t 
YBY ,t 


YBZ,t 
YCX,t 


YCY ,t
YCZ,t

=
1
1
0
0

1
0

0
1

0
0

0
0

0
0

0
0
1
1
0
0
0
1
0
0
1
0
0
0
0
0
0
0
AX
AY
AZ
A
BX
BY
BZ
B
CX
CY
CZ
C
X
Y
Z
Total

1
1
0
0
0
0
1
0
0
1
0
0
0
0
0
0
1
0
1
0
1
0
0
0
0
0
1
0
0
0
0
0
Fast computation of reconciled forecasts
|
1
0
1
0
0
1
0
0
0
0
0
1
0
0
0
0
{z
1
0
1
0
0
0
1
0
0
0
0
0
1
0
0
0
1
0
0
1
1
0
0
0
0
0
0
0
0
1
0
0
1
0
0
1
0
1
0
0
0
0
0
0
0
0
1
0
1
0

0 
YAX,t
1

0 YAY ,t 


0
 YAZ,t 

1 
YBX,t 


0 
Y 
0  BY ,t 

0 YBZ,t 


0 YCX,t 


0  Y
CY ,t
0
 YCZ,t
0
| {z }
0
Bt
1
Optimally reconciled forecasts
}
4
Grouped data

Yt =

Yt
Y
 A,t 
 YB,t 
 YC,t 


 YX,t 
 YY ,t 


 YZ,t 
YAX,t 


YAY ,t 
YAZ,t 


YBX,t 
YBY ,t 


YBZ,t 
YCX,t 


YCY ,t
YCZ,t

=
1
1
0
0

1
0

0
1

0
0

0
0

0
0

0
0
1
1
0
0
0
1
0
0
1
0
0
0
0
0
0
0
AX
AY
AZ
A
BX
BY
BZ
B
CX
CY
CZ
C
X
Y
Z
Total

1
1
0
0
0
0
1
0
0
1
0
0
0
0
0
0
1
0
1
0
1
0
0
0
0
0
1
0
0
0
0
0
Fast computation of reconciled forecasts
|
1
0
1
0
0
1
0
0
0
0
0
1
0
0
0
0
{z
1
0
1
0
0
0
1
0
0
0
0
0
1
0
0
0
1
0
0
1
1
0
0
0
0
0
0
0
0
1
0
0
1
0
0
1
0
1
0
0
0
0
0
0
0
0
1
0
1
0

0 
YAX,t
1

0 YAY ,t 


0
 YAZ,t 

1 
YBX,t 


0 
Y 
0  BY ,t 

0 YBZ,t 


0 YCX,t 


0  Y
CY ,t
0
 YCZ,t
0
| {z }
0
Bt
1
Optimally reconciled forecasts
}
Yt = SBt
4
Forecasts
Key idea: forecast reconciliation
å Ignore structural constraints and forecast
every series of interest independently.
å Adjust forecasts to impose constraints.
Let Ŷn (h) be vector of initial h-step forecasts,
made at time n, stacked in same order as Yt .
Yt = SBt .
So Ŷn (h) = Sβn (h) + εh .
βn (h) = E[Bn+h | Y1 , . . . , Yn ].
εh has zero mean.
Estimate βn (h) using weighted least squares.
Fast computation of reconciled forecasts
Optimally reconciled forecasts
5
Forecasts
Key idea: forecast reconciliation
å Ignore structural constraints and forecast
every series of interest independently.
å Adjust forecasts to impose constraints.
Let Ŷn (h) be vector of initial h-step forecasts,
made at time n, stacked in same order as Yt .
Yt = SBt .
So Ŷn (h) = Sβn (h) + εh .
βn (h) = E[Bn+h | Y1 , . . . , Yn ].
εh has zero mean.
Estimate βn (h) using weighted least squares.
Fast computation of reconciled forecasts
Optimally reconciled forecasts
5
Forecasts
Key idea: forecast reconciliation
å Ignore structural constraints and forecast
every series of interest independently.
å Adjust forecasts to impose constraints.
Let Ŷn (h) be vector of initial h-step forecasts,
made at time n, stacked in same order as Yt .
Yt = SBt .
So Ŷn (h) = Sβn (h) + εh .
βn (h) = E[Bn+h | Y1 , . . . , Yn ].
εh has zero mean.
Estimate βn (h) using weighted least squares.
Fast computation of reconciled forecasts
Optimally reconciled forecasts
5
Forecasts
Key idea: forecast reconciliation
å Ignore structural constraints and forecast
every series of interest independently.
å Adjust forecasts to impose constraints.
Let Ŷn (h) be vector of initial h-step forecasts,
made at time n, stacked in same order as Yt .
Yt = SBt .
So Ŷn (h) = Sβn (h) + εh .
βn (h) = E[Bn+h | Y1 , . . . , Yn ].
εh has zero mean.
Estimate βn (h) using weighted least squares.
Fast computation of reconciled forecasts
Optimally reconciled forecasts
5
Forecasts
Key idea: forecast reconciliation
å Ignore structural constraints and forecast
every series of interest independently.
å Adjust forecasts to impose constraints.
Let Ŷn (h) be vector of initial h-step forecasts,
made at time n, stacked in same order as Yt .
Yt = SBt .
So Ŷn (h) = Sβn (h) + εh .
βn (h) = E[Bn+h | Y1 , . . . , Yn ].
εh has zero mean.
Estimate βn (h) using weighted least squares.
Fast computation of reconciled forecasts
Optimally reconciled forecasts
5
Forecasts
Key idea: forecast reconciliation
å Ignore structural constraints and forecast
every series of interest independently.
å Adjust forecasts to impose constraints.
Let Ŷn (h) be vector of initial h-step forecasts,
made at time n, stacked in same order as Yt .
Yt = SBt .
So Ŷn (h) = Sβn (h) + εh .
βn (h) = E[Bn+h | Y1 , . . . , Yn ].
εh has zero mean.
Estimate βn (h) using weighted least squares.
Fast computation of reconciled forecasts
Optimally reconciled forecasts
5
Forecasts
Key idea: forecast reconciliation
å Ignore structural constraints and forecast
every series of interest independently.
å Adjust forecasts to impose constraints.
Let Ŷn (h) be vector of initial h-step forecasts,
made at time n, stacked in same order as Yt .
Yt = SBt .
So Ŷn (h) = Sβn (h) + εh .
βn (h) = E[Bn+h | Y1 , . . . , Yn ].
εh has zero mean.
Estimate βn (h) using weighted least squares.
Fast computation of reconciled forecasts
Optimally reconciled forecasts
5
Optimal reconciled forecasts
Ỹn (h) = Sβ̂n (h) = S(S0 ΛS)−1 S0 ΛŶn (h)
Λ weights (usually inverse of one-step
forecast variances, but any choice possible).
Easy to estimate, and places weight where
we have best forecasts.
Ignores covariances.
Still difficult to compute for large numbers
of time series.
Need to do calculation without explicitly
forming S or (S0ΛS)−1 or S0Λ.
Fast computation of reconciled forecasts
Optimally reconciled forecasts
6
Optimal reconciled forecasts
Ỹn (h) = Sβ̂n (h) = S(S0 ΛS)−1 S0 ΛŶn (h)
Initial forecasts
Λ weights (usually inverse of one-step
forecast variances, but any choice possible).
Easy to estimate, and places weight where
we have best forecasts.
Ignores covariances.
Still difficult to compute for large numbers
of time series.
Need to do calculation without explicitly
forming S or (S0ΛS)−1 or S0Λ.
Fast computation of reconciled forecasts
Optimally reconciled forecasts
6
Optimal reconciled forecasts
Ỹn (h) = Sβ̂n (h) = S(S0 ΛS)−1 S0 ΛŶn (h)
Revised forecasts
Initial forecasts
Λ weights (usually inverse of one-step
forecast variances, but any choice possible).
Easy to estimate, and places weight where
we have best forecasts.
Ignores covariances.
Still difficult to compute for large numbers
of time series.
Need to do calculation without explicitly
forming S or (S0ΛS)−1 or S0Λ.
Fast computation of reconciled forecasts
Optimally reconciled forecasts
6
Optimal reconciled forecasts
Ỹn (h) = Sβ̂n (h) = S(S0 ΛS)−1 S0 ΛŶn (h)
Revised forecasts
Initial forecasts
Λ weights (usually inverse of one-step
forecast variances, but any choice possible).
Easy to estimate, and places weight where
we have best forecasts.
Ignores covariances.
Still difficult to compute for large numbers
of time series.
Need to do calculation without explicitly
forming S or (S0ΛS)−1 or S0Λ.
Fast computation of reconciled forecasts
Optimally reconciled forecasts
6
Optimal reconciled forecasts
Ỹn (h) = Sβ̂n (h) = S(S0 ΛS)−1 S0 ΛŶn (h)
Revised forecasts
Initial forecasts
Λ weights (usually inverse of one-step
forecast variances, but any choice possible).
Easy to estimate, and places weight where
we have best forecasts.
Ignores covariances.
Still difficult to compute for large numbers
of time series.
Need to do calculation without explicitly
forming S or (S0ΛS)−1 or S0Λ.
Fast computation of reconciled forecasts
Optimally reconciled forecasts
6
Optimal reconciled forecasts
Ỹn (h) = Sβ̂n (h) = S(S0 ΛS)−1 S0 ΛŶn (h)
Revised forecasts
Initial forecasts
Λ weights (usually inverse of one-step
forecast variances, but any choice possible).
Easy to estimate, and places weight where
we have best forecasts.
Ignores covariances.
Still difficult to compute for large numbers
of time series.
Need to do calculation without explicitly
forming S or (S0ΛS)−1 or S0Λ.
Fast computation of reconciled forecasts
Optimally reconciled forecasts
6
Optimal reconciled forecasts
Ỹn (h) = Sβ̂n (h) = S(S0 ΛS)−1 S0 ΛŶn (h)
Revised forecasts
Initial forecasts
Λ weights (usually inverse of one-step
forecast variances, but any choice possible).
Easy to estimate, and places weight where
we have best forecasts.
Ignores covariances.
Still difficult to compute for large numbers
of time series.
Need to do calculation without explicitly
forming S or (S0ΛS)−1 or S0Λ.
Fast computation of reconciled forecasts
Optimally reconciled forecasts
6
Outline
1
Optimally reconciled forecasts
2
Fast computation
3
hts package for R
4
References
Fast computation of reconciled forecasts
Fast computation
7
Fast computation: hierarchical data
Total
A
AX






Yt = 





AY
Yt
YA,t
YB,t
YC,t
YAX,t
YAY ,t
YAZ,t
YBX,t
YBY ,t
YBZ,t
YCX,t
YCY ,t
YCZ,t

C
B
AZ
BX
1
1
 0
 0
 1
 
 0
 = 0
 0
 0
 
 0
 0
0
0
1
1
0
0
0
1
0
0
0
0
0
0
0
1
1
0
0
0
0
1
0
0
0
0
0
0
1
0
1
0
0
0
0
1
0
0
0
0
0
|
Fast computation of reconciled forecasts
BY
1
0
1
0
0
0
0
0
1
0
0
0
0
{z
S
1
0
1
0
0
0
0
0
0
1
0
0
0
CX
BZ
1
0
0
1
0
0
0
0
0
0
1
0
0
1
0
0
1
0
0
0
0
0
0
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
1
CY
CZ

YAX,t 
 YAY,t
Y 
 AZ,t 
YBX,t 
YBY,t 
YBZ,t 
Y 
 CX,t
 YCY,t
 YCZ,t
| {z }
Bt
Yt = SBt
}
Fast computation
8
Fast computation: hierarchies
Think of the hierarchy as a tree of trees:
Total
T1
T2
...
TK
Then the summing matrix contains k smaller summing
matrices:
 0

1n1 10n2 · · · 10nK
 S1 0 · · · 0 


0 S2 · · · 0 
S=
 .
..
.. 
...
 ..
.
. 
0
0 · · · SK
where 1n is an n-vector of ones and tree Ti has ni
terminal nodes.
Fast computation of reconciled forecasts
Fast computation
9
Fast computation: hierarchies
Think of the hierarchy as a tree of trees:
Total
T1
T2
...
TK
Then the summing matrix contains k smaller summing
matrices:
 0

1n1 10n2 · · · 10nK
 S1 0 · · · 0 


0 S2 · · · 0 
S=
 .
..
.. 
...
 ..
.
. 
0
0 · · · SK
where 1n is an n-vector of ones and tree Ti has ni
terminal nodes.
Fast computation of reconciled forecasts
Fast computation
9
Fast computation: hierarchies
S01 Λ1 S1
0
···

0
S02 Λ2 S2 · · ·

..
..
...

.
.

S0ΛS
=
0
0
0
0
..
.


+λ0 Jn

· · · S0K ΛK SK
λ0 is the top left element of Λ;
Λk is a block of Λ, corresponding to tree Tk ;
Jn is a matrix of ones;
P
n=
k nk .
Now apply the Sherman-Morrison formula . . .
Fast computation of reconciled forecasts
Fast computation
10
Fast computation: hierarchies
S01 Λ1 S1
0
···

0
S02 Λ2 S2 · · ·

..
..
...

.
.

S0ΛS
=
0
0
0
0
..
.


+λ0 Jn

· · · S0K ΛK SK
λ0 is the top left element of Λ;
Λk is a block of Λ, corresponding to tree Tk ;
Jn is a matrix of ones;
P
n=
k nk .
Now apply the Sherman-Morrison formula . . .
Fast computation of reconciled forecasts
Fast computation
10
Fast computation: hierarchies

(S0ΛS)−1
(S01 Λ1 S1 )−1
0

0
0
(S2 Λ2 S2 )−1

=
..
..

.
.
0
0
···
···
..
.
0
0
..
.
· · · (S0K ΛK SK )−1



−cS0

S0 can be partitioned into K 2 blocks, with the (k , `)
block (of dimension nk × n` ) being
(S0k Λk Sk )−1 Jnk ,n` (S0` Λ` S` )−1
Jnk ,n` is a nk × n` matrix of ones.
1
c−1 = λ−
0 +
X
10nk (S0k Λk Sk )−1 1nk .
k
Each S0k Λk Sk can be inverted similarly.
S0ΛY can also be computed recursively.
Fast computation of reconciled forecasts
Fast computation
11
Fast computation: hierarchies

(S0ΛS)−1
(S01 Λ1 S1 )−1
0

0
0
(S2 Λ2 S2 )−1

=
..
..

.
.
0
0
···
···
..
.
0
0
..
.
· · · (S0K ΛK SK )−1



−cS0

S0 can be partitioned into K 2 blocks, with the (k , `)
block (of dimension nk × n` ) being
The recursive
calculations can be
(S0k Λk Sk )−1 Jnk ,n` (S0` Λ` S` )−1
done in such a way that we never
Jnk ,n` store
is a nkany
× n`of
of ones.
the large
matrices
X matrix
−1
0
−1
−1
0
c =involved.
λ0 +
1nk (Sk Λk Sk ) 1nk .
k
Each S0k Λk Sk can be inverted similarly.
S0ΛY can also be computed recursively.
Fast computation of reconciled forecasts
Fast computation
11
Fast computation: grouped data

Yt


1
 YA,t  1
 YB,t  0
 YC,t  0

 
 YX,t  1
 YY ,t  0

 
 YZ,t  0
YAX,t  1
 
Yt = 
YAY ,t  = 0
YAZ,t  0

 
YBX,t  0
YBY ,t  0

 
YBZ,t  0
YCX,t  0

 
0
0
YCY ,t
YCZ,t
1
1
0
0
0
1
0
0
1
0
0
0
0
0
0
0
AX
AY
AZ
A
BX
BY
BZ
B
CX
CY
CZ
C
X
Y
Z
Total

1
1
0
0
0
0
1
0
0
1
0
0
0
0
0
0
1
0
1
0
1
0
0
0
0
0
1
0
0
0
0
0
Fast computation of reconciled forecasts
|
1
0
1
0
0
1
0
0
0
0
0
1
0
0
0
0
{z
1
0
1
0
0
0
1
0
0
0
0
0
1
0
0
0
1
0
0
1
1
0
0
0
0
0
0
0
0
1
0
0
1
0
0
1
0
1
0
0
0
0
0
0
0
0
1
0
1
0

0 
YAX,t
1
 Y 
0 
 AY ,t 
0
 YAZ,t 

1 
 YBX,t 

0 
Y 
0  BY ,t 

0 YBZ,t 


0 YCX,t 


0  Y
CY ,t
0
 YCZ,t
0
| {z }
0
Bt
1
}Fast computation
Yt = SBt
12
Fast computation: grouped data
10m ⊗ 10n
 10m ⊗ In 


 Im ⊗ 10n 
Im ⊗ In

S
=
S0ΛS

m = number of rows
n = number of columns
= λ00 Jmn + (ΛR ⊗ Jn) + (Jm ⊗ ΛC) + ΛU
ΛR, ΛC and ΛU are diagonal matrices
corresponding to rows, columns and
unaggregated series;
λ00 corresponds to aggregate.
Fast computation of reconciled forecasts
Fast computation
13
Fast computation: grouped data
10m ⊗ 10n
 10m ⊗ In 


 Im ⊗ 10n 
Im ⊗ In

S
=
S0ΛS

m = number of rows
n = number of columns
= λ00 Jmn + (ΛR ⊗ Jn) + (Jm ⊗ ΛC) + ΛU
ΛR, ΛC and ΛU are diagonal matrices
corresponding to rows, columns and
unaggregated series;
λ00 corresponds to aggregate.
Fast computation of reconciled forecasts
Fast computation
13
Fast computation: grouped data
(SΛS)
−1
=A−
A1mn 10mn A
1/λ00
+ 10mnA1mn
1
−1
−1
−1 0
A = Λ−
E.
U − ΛU (Jm ⊗ D)ΛU − EM
P
1
D is diagonal with elements dj = λ0j /(1 + λ0j i λ−
ij ).
E has m × m blocks where eij has kth element
(
(eij )k =
1/2
1/ 2
λi0 λ−ik1 − λi0 λ−ik2 dk , i = j,
1/2
−λj0 λ−ik1 λ−jk1 dk ,
i=
6 j.
M is m × m with (i, j) element
(
(M)ij =
1 + λi0
1/ 2
−1
i0
k ik
k
1/ 2 P
−1 −1
k ik
j0
jk dk
P
−λi0 λ
Fast computation of reconciled forecasts
λ
−λ
λ λ
P
−2
λik
dk , i = j,
,
i 6= j.
Fast computation
14
Fast computation: grouped data
(SΛS)
−1
=A−
A1mn 10mn A
1/λ00
+ 10mnA1mn
1
−1
−1
−1 0
A = Λ−
E.
U − ΛU (Jm ⊗ D)ΛU − EM
P
1
D is diagonal with elements dj = λ0j /(1 + λ0j i λ−
ij ).
E has m × m blocks where eij has kth element
(
1/2 −1
1/ 2 − 2
Again, theλcalculations
can be done
i0 λik − λi0 λik dk , i = j,
(in
eij )k =
1/2 −1 we
such a way
store
−λj0 that
λik λ−jk1 dnever
i 6= j.
k,
any of the large matrices involved.
M is m × m with (i, j) element
(
(M)ij =
1 + λi0
1/ 2
−1
i0
k ik
k
1/ 2 P
−1 −1
k ik
j0
jk dk
P
−λi0 λ
Fast computation of reconciled forecasts
λ
−λ
λ λ
P
−2
λik
dk , i = j,
,
i 6= j.
Fast computation
14
Fast computation
When the time series are not strictly
hierarchical and have more than two grouping
variables:
Use sparse matrix storage and arithmetic.
Use iterative approximation for inverting
large sparse matrices.
Paige & Saunders (1982)
ACM Trans. Math. Software
Fast computation of reconciled forecasts
Fast computation
15
Fast computation
When the time series are not strictly
hierarchical and have more than two grouping
variables:
Use sparse matrix storage and arithmetic.
Use iterative approximation for inverting
large sparse matrices.
Paige & Saunders (1982)
ACM Trans. Math. Software
Fast computation of reconciled forecasts
Fast computation
15
Fast computation
When the time series are not strictly
hierarchical and have more than two grouping
variables:
Use sparse matrix storage and arithmetic.
Use iterative approximation for inverting
large sparse matrices.
Paige & Saunders (1982)
ACM Trans. Math. Software
Fast computation of reconciled forecasts
Fast computation
15
Outline
1
Optimally reconciled forecasts
2
Fast computation
3
hts package for R
4
References
Fast computation of reconciled forecasts
hts package for R
16
hts package for R
hts: Hierarchical and grouped time series
Methods for analysing and forecasting hierarchical and grouped
time series
Version:
Depends:
Imports:
Published:
Author:
Maintainer:
BugReports:
License:
4.3
forecast (≥ 5.0)
SparseM, parallel, utils
2014-06-10
Rob J Hyndman, Earo Wang and Alan Lee
Rob J Hyndman <Rob.Hyndman at monash.edu>
https://github.com/robjhyndman/hts/issues
GPL (≥ 2)
Fast computation of reconciled forecasts
hts package for R
17
Example using R
library(hts)
# bts is a matrix containing the bottom level time series
# nodes describes the hierarchical structure
y <- hts(bts, nodes=list(2, c(3,2)))
Fast computation of reconciled forecasts
hts package for R
18
Example using R
library(hts)
# bts is a matrix containing the bottom level time series
# nodes describes the hierarchical structure
y <- hts(bts, nodes=list(2, c(3,2)))
Total
A
AX
Fast computation of reconciled forecasts
AY
B
AZ
hts package for R
BX
BY
18
Example using R
library(hts)
# bts is a matrix containing the bottom level time series
# nodes describes the hierarchical structure
y <- hts(bts, nodes=list(2, c(3,2)))
# Forecast 10-step-ahead using WLS combination method
# ETS used for each series by default
fc <- forecast(y, h=10)
Fast computation of reconciled forecasts
hts package for R
19
forecast.gts function
Usage
forecast(object, h,
method = c("comb", "bu", "mo", "tdgsf", "tdgsa", "tdfp"),
fmethod = c("ets", "rw", "arima"),
weights = c("sd", "none", "nseries"),
positive = FALSE,
parallel = FALSE, num.cores = 2, ...)
Arguments
object
h
method
fmethod
positive
weights
parallel
num.cores
Hierarchical time series object of class gts.
Forecast horizon
Method for distributing forecasts within the hierarchy.
Forecasting method to use
If TRUE, forecasts are forced to be strictly positive
Weights used for "optimal combination" method.
When
weights = "sd", it takes account of the standard deviation of
forecasts.
If TRUE, allow parallel processing
If parallel = TRUE, specify how many cores are going to be
used
Fast computation of reconciled forecasts
hts package for R
20
Outline
1
Optimally reconciled forecasts
2
Fast computation
3
hts package for R
4
References
Fast computation of reconciled forecasts
References
21
References
RJ Hyndman, RA Ahmed, G Athanasopoulos, and
HL Shang (Sept. 2011). “Optimal combination
forecasts for hierarchical time series”.
Computational statistics & data analysis 55(9),
2579–2589.
RJ Hyndman, AJ Lee, and E Wang (2014). Fast
computation of reconciled forecasts for hierarchical
and grouped time series. Working paper 17/14.
Department of Econometrics & Business Statistics,
Monash University
RJ Hyndman, AJ Lee, and E Wang (2014). hts:
Hierarchical and grouped time series.
cran.r-project.org/package=hts.
RJ Hyndman and G Athanasopoulos (2014).
Forecasting: principles and practice. OTexts.
FastOTexts.org/fpp/.
computation of reconciled forecasts
References
22
References
RJ Hyndman, RA Ahmed, G Athanasopoulos, and
HL Shang (Sept. 2011). “Optimal combination
forecasts for hierarchical time series”.
Computational statistics & data analysis 55(9),
2579–2589.
RJ Hyndman, AJ Lee, and E Wang (2014). Fast
computation of reconciled forecasts for hierarchical
and grouped time series. Working paper 17/14.
Department of Econometrics & Business Statistics,
Monash University
Hyndman,
AJ R
Lee,
and E Wang (2014). hts:
å RJ
Papers
and
code:
Hierarchical and grouped time series.
robjhyndman.com
cran.r-project.org/package=hts.
Hyndman
and G Athanasopoulos (2014).
å RJ
Email:
Rob.Hyndman@monash.edu
Forecasting: principles and practice. OTexts.
FastOTexts.org/fpp/.
computation of reconciled forecasts
References
22
Download