SlideShare a Scribd company logo
Total
A
AA AB AC
B
BA BB BC
C
CA CB CC
1
Rob J Hyndman
tools for hierarchical
time series
Introduction
Total
A
AA AB AC
B
BA BB BC
C
CA CB CC
Examples
Manufacturing product hierarchies
Pharmaceutical sales
Net labour turnover
hts: R tools for hierarchical time series 2
Introduction
Total
A
AA AB AC
B
BA BB BC
C
CA CB CC
Examples
Manufacturing product hierarchies
Pharmaceutical sales
Net labour turnover
hts: R tools for hierarchical time series 2
Introduction
Total
A
AA AB AC
B
BA BB BC
C
CA CB CC
Examples
Manufacturing product hierarchies
Pharmaceutical sales
Net labour turnover
hts: R tools for hierarchical time series 2
Introduction
Total
A
AA AB AC
B
BA BB BC
C
CA CB CC
Examples
Manufacturing product hierarchies
Pharmaceutical sales
Net labour turnover
hts: R tools for hierarchical time series 2
Hierarchical/grouped time series
A hierarchical time series is a collection of
several time series that are linked together in a
hierarchical structure.
Example: Pharmaceutical products are organized in
a hierarchy under the Anatomical Therapeutic
Chemical (ATC) Classification System.
A grouped time series is a collection of time
series that are aggregated in a number of
non-hierarchical ways.
Example: daily numbers of calls to HP call centres
are grouped by product type and location of call
centre.
hts: R tools for hierarchical time series 3
Hierarchical/grouped time series
A hierarchical time series is a collection of
several time series that are linked together in a
hierarchical structure.
Example: Pharmaceutical products are organized in
a hierarchy under the Anatomical Therapeutic
Chemical (ATC) Classification System.
A grouped time series is a collection of time
series that are aggregated in a number of
non-hierarchical ways.
Example: daily numbers of calls to HP call centres
are grouped by product type and location of call
centre.
hts: R tools for hierarchical time series 3
Hierarchical/grouped time series
A hierarchical time series is a collection of
several time series that are linked together in a
hierarchical structure.
Example: Pharmaceutical products are organized in
a hierarchy under the Anatomical Therapeutic
Chemical (ATC) Classification System.
A grouped time series is a collection of time
series that are aggregated in a number of
non-hierarchical ways.
Example: daily numbers of calls to HP call centres
are grouped by product type and location of call
centre.
hts: R tools for hierarchical time series 3
Hierarchical/grouped time series
A hierarchical time series is a collection of
several time series that are linked together in a
hierarchical structure.
Example: Pharmaceutical products are organized in
a hierarchy under the Anatomical Therapeutic
Chemical (ATC) Classification System.
A grouped time series is a collection of time
series that are aggregated in a number of
non-hierarchical ways.
Example: daily numbers of calls to HP call centres
are grouped by product type and location of call
centre.
hts: R tools for hierarchical time series 3
Hierarchical/grouped time series
Forecasts should be “aggregate
consistent”, unbiased, minimum variance.
Existing methods:
¢ Bottom-up
¢ Top-down
¢ Middle-out
How to compute forecast intervals?
Most research is concerned about relative
performance of existing methods.
There is no research on how to deal with
forecasting grouped time series.
hts: R tools for hierarchical time series 4
Hierarchical/grouped time series
Forecasts should be “aggregate
consistent”, unbiased, minimum variance.
Existing methods:
¢ Bottom-up
¢ Top-down
¢ Middle-out
How to compute forecast intervals?
Most research is concerned about relative
performance of existing methods.
There is no research on how to deal with
forecasting grouped time series.
hts: R tools for hierarchical time series 4
Hierarchical/grouped time series
Forecasts should be “aggregate
consistent”, unbiased, minimum variance.
Existing methods:
¢ Bottom-up
¢ Top-down
¢ Middle-out
How to compute forecast intervals?
Most research is concerned about relative
performance of existing methods.
There is no research on how to deal with
forecasting grouped time series.
hts: R tools for hierarchical time series 4
Hierarchical/grouped time series
Forecasts should be “aggregate
consistent”, unbiased, minimum variance.
Existing methods:
¢ Bottom-up
¢ Top-down
¢ Middle-out
How to compute forecast intervals?
Most research is concerned about relative
performance of existing methods.
There is no research on how to deal with
forecasting grouped time series.
hts: R tools for hierarchical time series 4
Hierarchical/grouped time series
Forecasts should be “aggregate
consistent”, unbiased, minimum variance.
Existing methods:
¢ Bottom-up
¢ Top-down
¢ Middle-out
How to compute forecast intervals?
Most research is concerned about relative
performance of existing methods.
There is no research on how to deal with
forecasting grouped time series.
hts: R tools for hierarchical time series 4
Hierarchical/grouped time series
Forecasts should be “aggregate
consistent”, unbiased, minimum variance.
Existing methods:
¢ Bottom-up
¢ Top-down
¢ Middle-out
How to compute forecast intervals?
Most research is concerned about relative
performance of existing methods.
There is no research on how to deal with
forecasting grouped time series.
hts: R tools for hierarchical time series 4
Hierarchical/grouped time series
Forecasts should be “aggregate
consistent”, unbiased, minimum variance.
Existing methods:
¢ Bottom-up
¢ Top-down
¢ Middle-out
How to compute forecast intervals?
Most research is concerned about relative
performance of existing methods.
There is no research on how to deal with
forecasting grouped time series.
hts: R tools for hierarchical time series 4
Hierarchical/grouped time series
Forecasts should be “aggregate
consistent”, unbiased, minimum variance.
Existing methods:
¢ Bottom-up
¢ Top-down
¢ Middle-out
How to compute forecast intervals?
Most research is concerned about relative
performance of existing methods.
There is no research on how to deal with
forecasting grouped time series.
hts: R tools for hierarchical time series 4
Hierarchical data
Total
A B C
hts: R tools for hierarchical time series 5
Yt : observed aggregate of all
series at time t.
YX,t : observation on series X at
time t.
Bt : vector of all series at
bottom level in time t.
Hierarchical data
Total
A B C
hts: R tools for hierarchical time series 5
Yt : observed aggregate of all
series at time t.
YX,t : observation on series X at
time t.
Bt : vector of all series at
bottom level in time t.
Hierarchical data
Total
A B C
Yt = [Yt, YA,t, YB,t, YC,t] =




1 1 1
1 0 0
0 1 0
0 0 1






YA,t
YB,t
YC,t


hts: R tools for hierarchical time series 5
Yt : observed aggregate of all
series at time t.
YX,t : observation on series X at
time t.
Bt : vector of all series at
bottom level in time t.
Hierarchical data
Total
A B C
Yt = [Yt, YA,t, YB,t, YC,t] =




1 1 1
1 0 0
0 1 0
0 0 1




S


YA,t
YB,t
YC,t


hts: R tools for hierarchical time series 5
Yt : observed aggregate of all
series at time t.
YX,t : observation on series X at
time t.
Bt : vector of all series at
bottom level in time t.
Hierarchical data
Total
A B C
Yt = [Yt, YA,t, YB,t, YC,t] =




1 1 1
1 0 0
0 1 0
0 0 1




S


YA,t
YB,t
YC,t


Bt
hts: R tools for hierarchical time series 5
Yt : observed aggregate of all
series at time t.
YX,t : observation on series X at
time t.
Bt : vector of all series at
bottom level in time t.
Hierarchical data
Total
A B C
Yt = [Yt, YA,t, YB,t, YC,t] =




1 1 1
1 0 0
0 1 0
0 0 1




S


YA,t
YB,t
YC,t


Bt
Yt = SBt
hts: R tools for hierarchical time series 5
Yt : observed aggregate of all
series at time t.
YX,t : observation on series X at
time t.
Bt : vector of all series at
bottom level in time t.
Hierarchical data
Total
A
AX AY AZ
B
BX BY BZ
C
CX CY CZ
Yt =












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












=












1 1 1 1 1 1 1 1 1
1 1 1 0 0 0 0 0 0
0 0 0 1 1 1 0 0 0
0 0 0 0 0 0 1 1 1
1 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0
0 0 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 1












S







YAX,t
YAY,t
YAZ,t
YBX,t
YBY,t
YBZ,t
YCX,t
YCY,t
YCZ,t







Bt
hts: R tools for hierarchical time series 6
Hierarchical data
Total
A
AX AY AZ
B
BX BY BZ
C
CX CY CZ
Yt =












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












=












1 1 1 1 1 1 1 1 1
1 1 1 0 0 0 0 0 0
0 0 0 1 1 1 0 0 0
0 0 0 0 0 0 1 1 1
1 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0
0 0 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 1












S







YAX,t
YAY,t
YAZ,t
YBX,t
YBY,t
YBZ,t
YCX,t
YCY,t
YCZ,t







Bt
hts: R tools for hierarchical time series 6
Hierarchical data
Total
A
AX AY AZ
B
BX BY BZ
C
CX CY CZ
Yt =












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












=












1 1 1 1 1 1 1 1 1
1 1 1 0 0 0 0 0 0
0 0 0 1 1 1 0 0 0
0 0 0 0 0 0 1 1 1
1 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0
0 0 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 1












S







YAX,t
YAY,t
YAZ,t
YBX,t
YBY,t
YBZ,t
YCX,t
YCY,t
YCZ,t







Bt
hts: R tools for hierarchical time series 6
Yt = SBt
Grouped data
Total
A
AX AY
B
BX BY
Total
X
AX BX
Y
AY BY
Yt =













Yt
YA,t
YB,t
YX,t
YY,t
YAX,t
YAY,t
YBX,t
YBY,t













=













1 1 1 1
1 1 0 0
0 0 1 1
1 0 1 0
0 1 0 1
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1













S



YAX,t
YAY,t
YBX,t
YBY,t



Bt
hts: R tools for hierarchical time series 7
Grouped data
Total
A
AX AY
B
BX BY
Total
X
AX BX
Y
AY BY
Yt =













Yt
YA,t
YB,t
YX,t
YY,t
YAX,t
YAY,t
YBX,t
YBY,t













=













1 1 1 1
1 1 0 0
0 0 1 1
1 0 1 0
0 1 0 1
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1













S



YAX,t
YAY,t
YBX,t
YBY,t



Bt
hts: R tools for hierarchical time series 7
Grouped data
Total
A
AX AY
B
BX BY
Total
X
AX BX
Y
AY BY
Yt =













Yt
YA,t
YB,t
YX,t
YY,t
YAX,t
YAY,t
YBX,t
YBY,t













=













1 1 1 1
1 1 0 0
0 0 1 1
1 0 1 0
0 1 0 1
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1













S



YAX,t
YAY,t
YBX,t
YBY,t



Bt
hts: R tools for hierarchical time series 7
Yt = SBt
Forecasts
Key idea: forecast reconciliation
¯ Ignore structural constraints and forecast
every series of interest independently.
¯ Adjust forecasts to impose constraints.
Let ˆYn(h) be vector of initial h-step forecasts,
made at time n, stacked in same order as Yt.
Yt = SBt . So ˆYn(h) = Sβn(h) + εh .
βn(h) = E[Bn+h | Y1, . . . , Yn].
εh has zero mean and covariance Σh.
Estimate βn(h) using GLS?
hts: R tools for hierarchical time series 8
Forecasts
Key idea: forecast reconciliation
¯ Ignore structural constraints and forecast
every series of interest independently.
¯ Adjust forecasts to impose constraints.
Let ˆYn(h) be vector of initial h-step forecasts,
made at time n, stacked in same order as Yt.
Yt = SBt . So ˆYn(h) = Sβn(h) + εh .
βn(h) = E[Bn+h | Y1, . . . , Yn].
εh has zero mean and covariance Σh.
Estimate βn(h) using GLS?
hts: R tools for hierarchical time series 8
Forecasts
Key idea: forecast reconciliation
¯ Ignore structural constraints and forecast
every series of interest independently.
¯ Adjust forecasts to impose constraints.
Let ˆYn(h) be vector of initial h-step forecasts,
made at time n, stacked in same order as Yt.
Yt = SBt . So ˆYn(h) = Sβn(h) + εh .
βn(h) = E[Bn+h | Y1, . . . , Yn].
εh has zero mean and covariance Σh.
Estimate βn(h) using GLS?
hts: R tools for hierarchical time series 8
Forecasts
Key idea: forecast reconciliation
¯ Ignore structural constraints and forecast
every series of interest independently.
¯ Adjust forecasts to impose constraints.
Let ˆYn(h) be vector of initial h-step forecasts,
made at time n, stacked in same order as Yt.
Yt = SBt . So ˆYn(h) = Sβn(h) + εh .
βn(h) = E[Bn+h | Y1, . . . , Yn].
εh has zero mean and covariance Σh.
Estimate βn(h) using GLS?
hts: R tools for hierarchical time series 8
Forecasts
Key idea: forecast reconciliation
¯ Ignore structural constraints and forecast
every series of interest independently.
¯ Adjust forecasts to impose constraints.
Let ˆYn(h) be vector of initial h-step forecasts,
made at time n, stacked in same order as Yt.
Yt = SBt . So ˆYn(h) = Sβn(h) + εh .
βn(h) = E[Bn+h | Y1, . . . , Yn].
εh has zero mean and covariance Σh.
Estimate βn(h) using GLS?
hts: R tools for hierarchical time series 8
Forecasts
Key idea: forecast reconciliation
¯ Ignore structural constraints and forecast
every series of interest independently.
¯ Adjust forecasts to impose constraints.
Let ˆYn(h) be vector of initial h-step forecasts,
made at time n, stacked in same order as Yt.
Yt = SBt . So ˆYn(h) = Sβn(h) + εh .
βn(h) = E[Bn+h | Y1, . . . , Yn].
εh has zero mean and covariance Σh.
Estimate βn(h) using GLS?
hts: R tools for hierarchical time series 8
Forecasts
Key idea: forecast reconciliation
¯ Ignore structural constraints and forecast
every series of interest independently.
¯ Adjust forecasts to impose constraints.
Let ˆYn(h) be vector of initial h-step forecasts,
made at time n, stacked in same order as Yt.
Yt = SBt . So ˆYn(h) = Sβn(h) + εh .
βn(h) = E[Bn+h | Y1, . . . , Yn].
εh has zero mean and covariance Σh.
Estimate βn(h) using GLS?
hts: R tools for hierarchical time series 8
Optimal combination forecasts
˜Yn(h) = S ˆβn(h) = S(S Σ†
hS)−1
S Σ†
h
ˆYn(h)
Σ†
h is generalized inverse of Σh.
Problem: Σh hard to estimate.
Solution: Assume εh ≈ SεK,h where εK,h is
the forecast error at bottom level.
Then Σh ≈ SΩhS where Ωh = Var(εK,h).
If Moore-Penrose generalized inverse used,
then (S Σ†
S)−1
S Σ†
= (S S)−1
S .
˜Yn(h) = S(S S)−1
S ˆYn(h)
hts: R tools for hierarchical time series 9
Optimal combination forecasts
˜Yn(h) = S ˆβn(h) = S(S Σ†
hS)−1
S Σ†
h
ˆYn(h)
Initial forecasts
Σ†
h is generalized inverse of Σh.
Problem: Σh hard to estimate.
Solution: Assume εh ≈ SεK,h where εK,h is
the forecast error at bottom level.
Then Σh ≈ SΩhS where Ωh = Var(εK,h).
If Moore-Penrose generalized inverse used,
then (S Σ†
S)−1
S Σ†
= (S S)−1
S .
˜Yn(h) = S(S S)−1
S ˆYn(h)
hts: R tools for hierarchical time series 9
Optimal combination forecasts
˜Yn(h) = S ˆβn(h) = S(S Σ†
hS)−1
S Σ†
h
ˆYn(h)
Revised forecasts Initial forecasts
Σ†
h is generalized inverse of Σh.
Problem: Σh hard to estimate.
Solution: Assume εh ≈ SεK,h where εK,h is
the forecast error at bottom level.
Then Σh ≈ SΩhS where Ωh = Var(εK,h).
If Moore-Penrose generalized inverse used,
then (S Σ†
S)−1
S Σ†
= (S S)−1
S .
˜Yn(h) = S(S S)−1
S ˆYn(h)
hts: R tools for hierarchical time series 9
Optimal combination forecasts
˜Yn(h) = S ˆβn(h) = S(S Σ†
hS)−1
S Σ†
h
ˆYn(h)
Revised forecasts Initial forecasts
Σ†
h is generalized inverse of Σh.
Problem: Σh hard to estimate.
Solution: Assume εh ≈ SεK,h where εK,h is
the forecast error at bottom level.
Then Σh ≈ SΩhS where Ωh = Var(εK,h).
If Moore-Penrose generalized inverse used,
then (S Σ†
S)−1
S Σ†
= (S S)−1
S .
˜Yn(h) = S(S S)−1
S ˆYn(h)
hts: R tools for hierarchical time series 9
Optimal combination forecasts
˜Yn(h) = S ˆβn(h) = S(S Σ†
hS)−1
S Σ†
h
ˆYn(h)
Revised forecasts Initial forecasts
Σ†
h is generalized inverse of Σh.
Problem: Σh hard to estimate.
Solution: Assume εh ≈ SεK,h where εK,h is
the forecast error at bottom level.
Then Σh ≈ SΩhS where Ωh = Var(εK,h).
If Moore-Penrose generalized inverse used,
then (S Σ†
S)−1
S Σ†
= (S S)−1
S .
˜Yn(h) = S(S S)−1
S ˆYn(h)
hts: R tools for hierarchical time series 9
Optimal combination forecasts
˜Yn(h) = S ˆβn(h) = S(S Σ†
hS)−1
S Σ†
h
ˆYn(h)
Revised forecasts Initial forecasts
Σ†
h is generalized inverse of Σh.
Problem: Σh hard to estimate.
Solution: Assume εh ≈ SεK,h where εK,h is
the forecast error at bottom level.
Then Σh ≈ SΩhS where Ωh = Var(εK,h).
If Moore-Penrose generalized inverse used,
then (S Σ†
S)−1
S Σ†
= (S S)−1
S .
˜Yn(h) = S(S S)−1
S ˆYn(h)
hts: R tools for hierarchical time series 9
Optimal combination forecasts
˜Yn(h) = S ˆβn(h) = S(S Σ†
hS)−1
S Σ†
h
ˆYn(h)
Revised forecasts Initial forecasts
Σ†
h is generalized inverse of Σh.
Problem: Σh hard to estimate.
Solution: Assume εh ≈ SεK,h where εK,h is
the forecast error at bottom level.
Then Σh ≈ SΩhS where Ωh = Var(εK,h).
If Moore-Penrose generalized inverse used,
then (S Σ†
S)−1
S Σ†
= (S S)−1
S .
˜Yn(h) = S(S S)−1
S ˆYn(h)
hts: R tools for hierarchical time series 9
Optimal combination forecasts
˜Yn(h) = S ˆβn(h) = S(S Σ†
hS)−1
S Σ†
h
ˆYn(h)
Revised forecasts Initial forecasts
Σ†
h is generalized inverse of Σh.
Problem: Σh hard to estimate.
Solution: Assume εh ≈ SεK,h where εK,h is
the forecast error at bottom level.
Then Σh ≈ SΩhS where Ωh = Var(εK,h).
If Moore-Penrose generalized inverse used,
then (S Σ†
S)−1
S Σ†
= (S S)−1
S .
˜Yn(h) = S(S S)−1
S ˆYn(h)
hts: R tools for hierarchical time series 9
Optimal combination forecasts
˜Yn(h) = S ˆβn(h) = S(S Σ†
hS)−1
S Σ†
h
ˆYn(h)
Revised forecasts Initial forecasts
Σ†
h is generalized inverse of Σh.
Problem: Σh hard to estimate.
Solution: Assume εh ≈ SεK,h where εK,h is
the forecast error at bottom level.
Then Σh ≈ SΩhS where Ωh = Var(εK,h).
If Moore-Penrose generalized inverse used,
then (S Σ†
S)−1
S Σ†
= (S S)−1
S .
˜Yn(h) = S(S S)−1
S ˆYn(h)
hts: R tools for hierarchical time series 9
Optimal combination forecasts
˜Yn(h) = S ˆβn(h) = S(S Σ†
hS)−1
S Σ†
h
ˆYn(h)
Revised forecasts Initial forecasts
Σ†
h is generalized inverse of Σh.
Problem: Σh hard to estimate.
Solution: Assume εh ≈ SεK,h where εK,h is
the forecast error at bottom level.
Then Σh ≈ SΩhS where Ωh = Var(εK,h).
If Moore-Penrose generalized inverse used,
then (S Σ†
S)−1
S Σ†
= (S S)−1
S .
˜Yn(h) = S(S S)−1
S ˆYn(h)
hts: R tools for hierarchical time series 9
Optimal combination forecasts
˜Yn(h) = S(S S)−1
S ˆYn(h)
GLS = OLS.
Optimal weighted average of initial
forecasts.
Optimal reconciliation weights are
S(S S)−1
S .
Weights are independent of the data and
of the covariance structure of the
hierarchy!
hts: R tools for hierarchical time series 10
Optimal combination forecasts
˜Yn(h) = S(S S)−1
S ˆYn(h)
GLS = OLS.
Optimal weighted average of initial
forecasts.
Optimal reconciliation weights are
S(S S)−1
S .
Weights are independent of the data and
of the covariance structure of the
hierarchy!
hts: R tools for hierarchical time series 10
Optimal combination forecasts
˜Yn(h) = S(S S)−1
S ˆYn(h)
GLS = OLS.
Optimal weighted average of initial
forecasts.
Optimal reconciliation weights are
S(S S)−1
S .
Weights are independent of the data and
of the covariance structure of the
hierarchy!
hts: R tools for hierarchical time series 10
Optimal combination forecasts
˜Yn(h) = S(S S)−1
S ˆYn(h)
GLS = OLS.
Optimal weighted average of initial
forecasts.
Optimal reconciliation weights are
S(S S)−1
S .
Weights are independent of the data and
of the covariance structure of the
hierarchy!
hts: R tools for hierarchical time series 10
Optimal combination forecasts
Total
A
AA AB AC
B
BA BB BC
C
CA CB CC
Weights: S(S S)−1
S =






















0.69 0.23 0.23 0.23 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08
0.23 0.58 −0.17 −0.17 0.19 0.19 0.19 −0.06 −0.06 −0.06 −0.06 −0.06 −0.06
0.23 −0.17 0.58 −0.17 −0.06 −0.06 −0.06 0.19 0.19 0.19 −0.06 −0.06 −0.06
0.23 −0.17 −0.17 0.58 −0.06 −0.06 −0.06 −0.06 −0.06 −0.06 0.19 0.19 0.19
0.08 0.19 −0.06 −0.06 0.73 −0.27 −0.27 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02
0.08 0.19 −0.06 −0.06 −0.27 0.73 −0.27 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02
0.08 0.19 −0.06 −0.06 −0.27 −0.27 0.73 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02
0.08 −0.06 0.19 −0.06 −0.02 −0.02 −0.02 0.73 −0.27 −0.27 −0.02 −0.02 −0.02
0.08 −0.06 0.19 −0.06 −0.02 −0.02 −0.02 −0.27 0.73 −0.27 −0.02 −0.02 −0.02
0.08 −0.06 0.19 −0.06 −0.02 −0.02 −0.02 −0.27 −0.27 0.73 −0.02 −0.02 −0.02
0.08 −0.06 −0.06 0.19 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 0.73 −0.27 −0.27
0.08 −0.06 −0.06 0.19 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 −0.27 0.73 −0.27
0.08 −0.06 −0.06 0.19 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 −0.27 −0.27 0.73






















hts: R tools for hierarchical time series 11
Optimal combination forecasts
Total
A
AA AB AC
B
BA BB BC
C
CA CB CC
Weights: S(S S)−1
S =






















0.69 0.23 0.23 0.23 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08
0.23 0.58 −0.17 −0.17 0.19 0.19 0.19 −0.06 −0.06 −0.06 −0.06 −0.06 −0.06
0.23 −0.17 0.58 −0.17 −0.06 −0.06 −0.06 0.19 0.19 0.19 −0.06 −0.06 −0.06
0.23 −0.17 −0.17 0.58 −0.06 −0.06 −0.06 −0.06 −0.06 −0.06 0.19 0.19 0.19
0.08 0.19 −0.06 −0.06 0.73 −0.27 −0.27 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02
0.08 0.19 −0.06 −0.06 −0.27 0.73 −0.27 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02
0.08 0.19 −0.06 −0.06 −0.27 −0.27 0.73 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02
0.08 −0.06 0.19 −0.06 −0.02 −0.02 −0.02 0.73 −0.27 −0.27 −0.02 −0.02 −0.02
0.08 −0.06 0.19 −0.06 −0.02 −0.02 −0.02 −0.27 0.73 −0.27 −0.02 −0.02 −0.02
0.08 −0.06 0.19 −0.06 −0.02 −0.02 −0.02 −0.27 −0.27 0.73 −0.02 −0.02 −0.02
0.08 −0.06 −0.06 0.19 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 0.73 −0.27 −0.27
0.08 −0.06 −0.06 0.19 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 −0.27 0.73 −0.27
0.08 −0.06 −0.06 0.19 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 −0.27 −0.27 0.73






















hts: R tools for hierarchical time series 11
Features
Forget “bottom up” or “top down”. This
approach combines all forecasts optimally.
Method outperforms bottom-up and
top-down, especially for middle levels.
Covariates can be included in initial forecasts.
Adjustments can be made to initial forecasts
at any level.
Very simple and flexible method. Can work
with any hierarchical or grouped time series.
Conceptually easy to implement: OLS on
base forecasts.
hts: R tools for hierarchical time series 12
Features
Forget “bottom up” or “top down”. This
approach combines all forecasts optimally.
Method outperforms bottom-up and
top-down, especially for middle levels.
Covariates can be included in initial forecasts.
Adjustments can be made to initial forecasts
at any level.
Very simple and flexible method. Can work
with any hierarchical or grouped time series.
Conceptually easy to implement: OLS on
base forecasts.
hts: R tools for hierarchical time series 12
Features
Forget “bottom up” or “top down”. This
approach combines all forecasts optimally.
Method outperforms bottom-up and
top-down, especially for middle levels.
Covariates can be included in initial forecasts.
Adjustments can be made to initial forecasts
at any level.
Very simple and flexible method. Can work
with any hierarchical or grouped time series.
Conceptually easy to implement: OLS on
base forecasts.
hts: R tools for hierarchical time series 12
Features
Forget “bottom up” or “top down”. This
approach combines all forecasts optimally.
Method outperforms bottom-up and
top-down, especially for middle levels.
Covariates can be included in initial forecasts.
Adjustments can be made to initial forecasts
at any level.
Very simple and flexible method. Can work
with any hierarchical or grouped time series.
Conceptually easy to implement: OLS on
base forecasts.
hts: R tools for hierarchical time series 12
Features
Forget “bottom up” or “top down”. This
approach combines all forecasts optimally.
Method outperforms bottom-up and
top-down, especially for middle levels.
Covariates can be included in initial forecasts.
Adjustments can be made to initial forecasts
at any level.
Very simple and flexible method. Can work
with any hierarchical or grouped time series.
Conceptually easy to implement: OLS on
base forecasts.
hts: R tools for hierarchical time series 12
Features
Forget “bottom up” or “top down”. This
approach combines all forecasts optimally.
Method outperforms bottom-up and
top-down, especially for middle levels.
Covariates can be included in initial forecasts.
Adjustments can be made to initial forecasts
at any level.
Very simple and flexible method. Can work
with any hierarchical or grouped time series.
Conceptually easy to implement: OLS on
base forecasts.
hts: R tools for hierarchical time series 12
Challenges
Computational difficulties in big
hierarchies due to size of the S matrix and
non-singular behavior of (S S).
Need to estimate covariance matrix to
produce prediction intervals.
hts: R tools for hierarchical time series 13
Challenges
Computational difficulties in big
hierarchies due to size of the S matrix and
non-singular behavior of (S S).
Need to estimate covariance matrix to
produce prediction intervals.
hts: R tools for hierarchical time series 13
hts package for R
hts: R tools for hierarchical time series 14
hts: Hierarchical and grouped time series
Methods for analysing and forecasting hierarchical and grouped
time series
Version: 3.01
Depends: forecast
Imports: SparseM
Published: 2013-05-07
Author: Rob J Hyndman, Roman A Ahmed, and Han Lin Shang
Maintainer: Rob J Hyndman <Rob.Hyndman at monash.edu>
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
Example using R
library(hts)
# bts is a matrix containing the bottom level time series
# g describes the grouping/hierarchical structure
y <- hts(bts, g=c(1,1,2,2))
hts: R tools for hierarchical time series 15
Example using R
library(hts)
# bts is a matrix containing the bottom level time series
# g describes the grouping/hierarchical structure
y <- hts(bts, g=c(1,1,2,2))
hts: R tools for hierarchical time series 15
Total
A
AX AY
B
BX BY
Example using R
library(hts)
# bts is a matrix containing the bottom level time series
# g describes the grouping/hierarchical structure
y <- hts(bts, g=c(1,1,2,2))
# Forecast 10-step-ahead using optimal combination method
# ETS used for each series by default
fc <- forecast(y, h=10)
hts: R tools for hierarchical time series 16
Example using R
library(hts)
# bts is a matrix containing the bottom level time series
# g describes the grouping/hierarchical structure
y <- hts(bts, g=c(1,1,2,2))
# Forecast 10-step-ahead using optimal combination method
# ETS used for each series by default
fc <- forecast(y, h=10)
# Select your own methods
ally <- allts(y)
allf <- matrix(, nrow=10, ncol=ncol(ally))
for(i in 1:ncol(ally))
allf[,i] <- mymethod(ally[,i], h=10)
allf <- ts(allf, start=2004)
# Reconcile forecasts so they add up
fc2 <- combinef(allf, Smatrix(y))
hts: R tools for hierarchical time series 17
hts function
Usage
hts(y, g)
gts(y, g, hierarchical=FALSE)
Arguments
y Multivariate time series containing the bot-
tom level series
g Group matrix indicating the group structure,
with one column for each series when com-
pletely disaggregated, and one row for each
grouping of the time series.
hierarchical Indicates if the grouping matrix should be
treated as hierarchical.
Details
hts is simply a wrapper for gts(y,g,TRUE). Both return an
object of class gts.
hts: R tools for hierarchical time series 18
forecast.gts function
Usage
forecast(object, h,
method = c("comb", "bu", "mo", "tdgsf", "tdgsa", "tdfp", "all"),
fmethod = c("ets", "rw", "arima"), level, positive = FALSE,
xreg = NULL, newxreg = NULL, ...)
Arguments
object Hierarchical time series object of class gts.
h Forecast horizon
method Method for distributing forecasts within the hierarchy.
fmethod Forecasting method to use
level Level used for "middle-out" method (when method="mo")
positive If TRUE, forecasts are forced to be strictly positive
xreg When fmethod = "arima", a vector or matrix of external re-
gressors, which must have the same number of rows as the
original univariate time series
newxreg When fmethod = "arima", a vector or matrix of external re-
gressors, which must have the same number of rows as the
original univariate time series
... Other arguments passing to ets or auto.arima
hts: R tools for hierarchical time series 19
Utility functions
allts(y) Returns all series in the
hierarchy
Smatrix(y) Returns the summing matrix
combinef(f) Combines initial forecasts
optimally.
hts: R tools for hierarchical time series 20
More information
hts: R tools for hierarchical time series 21
Vignette on CRAN
References
RJ Hyndman, RA Ahmed, G Athanasopoulos, and
HL Shang (2011). “Optimal combination
forecasts for hierarchical time series”.
Computational Statistics and Data Analysis
55(9), 2579–2589
RJ Hyndman, RA Ahmed, and HL Shang (2013).
hts: Hierarchical time series.
cran.r-project.org/package=hts.
RJ Hyndman and G Athanasopoulos (2013).
Forecasting: principles and practice. OTexts.
OTexts.com/fpp/.
hts: R tools for hierarchical time series 22

More Related Content

What's hot

金融時系列のための深層t過程回帰モデル
金融時系列のための深層t過程回帰モデル金融時系列のための深層t過程回帰モデル
金融時系列のための深層t過程回帰モデル
Kei Nakagawa
 
الرياضيات للصف الرابع الادبي
الرياضيات للصف الرابع الادبيالرياضيات للصف الرابع الادبي
الرياضيات للصف الرابع الادبي
Ayad Haris Beden
 
適切なクラスタ数を機械的に求める手法の紹介
適切なクラスタ数を機械的に求める手法の紹介適切なクラスタ数を機械的に求める手法の紹介
適切なクラスタ数を機械的に求める手法の紹介
Takeshi Mikami
 
並行プログラミングと継続モナド
並行プログラミングと継続モナド並行プログラミングと継続モナド
並行プログラミングと継続モナド
Kousuke Ruichi
 
F#によるFunctional Programming入門
F#によるFunctional Programming入門F#によるFunctional Programming入門
F#によるFunctional Programming入門
bleis tift
 
الحصون الخمسة في حفظ القرآن الكريم للأطفال
الحصون الخمسة في حفظ القرآن الكريم للأطفالالحصون الخمسة في حفظ القرآن الكريم للأطفال
يداً بيد لحفظ القرآن الكريــــم ( سورة البقرة مع أحكام التجويد الأساسية فيها
 يداً بيد لحفظ القرآن الكريــــم ( سورة البقرة مع أحكام التجويد الأساسية فيها   يداً بيد لحفظ القرآن الكريــــم ( سورة البقرة مع أحكام التجويد الأساسية فيها
يداً بيد لحفظ القرآن الكريــــم ( سورة البقرة مع أحكام التجويد الأساسية فيها
Maysoun67
 
CRAN Rパッケージ BNSLの概要
CRAN Rパッケージ BNSLの概要CRAN Rパッケージ BNSLの概要
CRAN Rパッケージ BNSLの概要
Joe Suzuki
 
Jubatusのリアルタイム分散レコメンデーション@TokyoNLP#9
Jubatusのリアルタイム分散レコメンデーション@TokyoNLP#9Jubatusのリアルタイム分散レコメンデーション@TokyoNLP#9
Jubatusのリアルタイム分散レコメンデーション@TokyoNLP#9Yuya Unno
 
矩陣 轉換
矩陣   轉換矩陣   轉換
矩陣 轉換
River Wang
 

What's hot (10)

金融時系列のための深層t過程回帰モデル
金融時系列のための深層t過程回帰モデル金融時系列のための深層t過程回帰モデル
金融時系列のための深層t過程回帰モデル
 
الرياضيات للصف الرابع الادبي
الرياضيات للصف الرابع الادبيالرياضيات للصف الرابع الادبي
الرياضيات للصف الرابع الادبي
 
適切なクラスタ数を機械的に求める手法の紹介
適切なクラスタ数を機械的に求める手法の紹介適切なクラスタ数を機械的に求める手法の紹介
適切なクラスタ数を機械的に求める手法の紹介
 
並行プログラミングと継続モナド
並行プログラミングと継続モナド並行プログラミングと継続モナド
並行プログラミングと継続モナド
 
F#によるFunctional Programming入門
F#によるFunctional Programming入門F#によるFunctional Programming入門
F#によるFunctional Programming入門
 
الحصون الخمسة في حفظ القرآن الكريم للأطفال
الحصون الخمسة في حفظ القرآن الكريم للأطفالالحصون الخمسة في حفظ القرآن الكريم للأطفال
الحصون الخمسة في حفظ القرآن الكريم للأطفال
 
يداً بيد لحفظ القرآن الكريــــم ( سورة البقرة مع أحكام التجويد الأساسية فيها
 يداً بيد لحفظ القرآن الكريــــم ( سورة البقرة مع أحكام التجويد الأساسية فيها   يداً بيد لحفظ القرآن الكريــــم ( سورة البقرة مع أحكام التجويد الأساسية فيها
يداً بيد لحفظ القرآن الكريــــم ( سورة البقرة مع أحكام التجويد الأساسية فيها
 
CRAN Rパッケージ BNSLの概要
CRAN Rパッケージ BNSLの概要CRAN Rパッケージ BNSLの概要
CRAN Rパッケージ BNSLの概要
 
Jubatusのリアルタイム分散レコメンデーション@TokyoNLP#9
Jubatusのリアルタイム分散レコメンデーション@TokyoNLP#9Jubatusのリアルタイム分散レコメンデーション@TokyoNLP#9
Jubatusのリアルタイム分散レコメンデーション@TokyoNLP#9
 
矩陣 轉換
矩陣   轉換矩陣   轉換
矩陣 轉換
 

Similar to R tools for hierarchical time series

Forecasting Hierarchical Time Series
Forecasting Hierarchical Time SeriesForecasting Hierarchical Time Series
Forecasting Hierarchical Time Series
Rob Hyndman
 
Ts 16949 quality management system
Ts 16949 quality management systemTs 16949 quality management system
Ts 16949 quality management systemselinasimpson381
 
Quality management in healthcare
Quality management in healthcareQuality management in healthcare
Quality management in healthcareselinasimpson0101
 
Quality and productivity management
Quality and productivity managementQuality and productivity management
Quality and productivity managementselinasimpson2201
 
Iso 9001 registered
Iso 9001 registeredIso 9001 registered
Iso 9001 registeredjomjenguta
 
Iso 9001 certified companies
Iso 9001 certified companiesIso 9001 certified companies
Iso 9001 certified companiesarikajom
 
Iso 9001 history
Iso 9001 historyIso 9001 history
Iso 9001 historyjomjenguta
 
Quality management software ltd
Quality management software ltdQuality management software ltd
Quality management software ltdselinasimpson3001
 
Project quality management definition
Project quality management definitionProject quality management definition
Project quality management definitionselinasimpson1001
 
Week 4 Interpreting Longitudinal Models (1).pptx
Week 4 Interpreting Longitudinal Models (1).pptxWeek 4 Interpreting Longitudinal Models (1).pptx
Week 4 Interpreting Longitudinal Models (1).pptx
Oyebayo Ridwan Olaniran
 
Iso 9001 consultants
Iso 9001 consultantsIso 9001 consultants
Iso 9001 consultantsjomharipe
 
Quality management system flowchart
Quality management system flowchartQuality management system flowchart
Quality management system flowchartselinasimpson2801
 
Iso 9001 quality policy
Iso 9001 quality policyIso 9001 quality policy
Iso 9001 quality policydenritafu
 
Quality management introduction
Quality management introductionQuality management introduction
Quality management introductionselinasimpson2801
 
Introduction to healthcare quality management
Introduction to healthcare quality managementIntroduction to healthcare quality management
Introduction to healthcare quality managementselinasimpson1401
 
Course in quality management
Course in quality managementCourse in quality management
Course in quality managementselinasimpson361
 
Iso 9001 audit
Iso 9001 auditIso 9001 audit
Iso 9001 auditjomharipe
 
File system in pediatric benghazi medical centre 2013
File system in pediatric benghazi medical centre 2013File system in pediatric benghazi medical centre 2013
File system in pediatric benghazi medical centre 2013
AlsalheenAlraied
 

Similar to R tools for hierarchical time series (20)

Forecasting Hierarchical Time Series
Forecasting Hierarchical Time SeriesForecasting Hierarchical Time Series
Forecasting Hierarchical Time Series
 
Ts 16949 quality management system
Ts 16949 quality management systemTs 16949 quality management system
Ts 16949 quality management system
 
Quality management in healthcare
Quality management in healthcareQuality management in healthcare
Quality management in healthcare
 
Quality and productivity management
Quality and productivity managementQuality and productivity management
Quality and productivity management
 
Iso 9001 uk
Iso 9001 ukIso 9001 uk
Iso 9001 uk
 
Iso 9001 registered
Iso 9001 registeredIso 9001 registered
Iso 9001 registered
 
Iso 9001 certified companies
Iso 9001 certified companiesIso 9001 certified companies
Iso 9001 certified companies
 
Iso 9001 history
Iso 9001 historyIso 9001 history
Iso 9001 history
 
Quality management software ltd
Quality management software ltdQuality management software ltd
Quality management software ltd
 
Project quality management definition
Project quality management definitionProject quality management definition
Project quality management definition
 
Week 4 Interpreting Longitudinal Models (1).pptx
Week 4 Interpreting Longitudinal Models (1).pptxWeek 4 Interpreting Longitudinal Models (1).pptx
Week 4 Interpreting Longitudinal Models (1).pptx
 
Iso 9001 consultants
Iso 9001 consultantsIso 9001 consultants
Iso 9001 consultants
 
Quality management system flowchart
Quality management system flowchartQuality management system flowchart
Quality management system flowchart
 
System quality management
System quality managementSystem quality management
System quality management
 
Iso 9001 quality policy
Iso 9001 quality policyIso 9001 quality policy
Iso 9001 quality policy
 
Quality management introduction
Quality management introductionQuality management introduction
Quality management introduction
 
Introduction to healthcare quality management
Introduction to healthcare quality managementIntroduction to healthcare quality management
Introduction to healthcare quality management
 
Course in quality management
Course in quality managementCourse in quality management
Course in quality management
 
Iso 9001 audit
Iso 9001 auditIso 9001 audit
Iso 9001 audit
 
File system in pediatric benghazi medical centre 2013
File system in pediatric benghazi medical centre 2013File system in pediatric benghazi medical centre 2013
File system in pediatric benghazi medical centre 2013
 

More from Rob Hyndman

Exploring the feature space of large collections of time series
Exploring the feature space of large collections of time seriesExploring the feature space of large collections of time series
Exploring the feature space of large collections of time series
Rob Hyndman
 
Automatic algorithms for time series forecasting
Automatic algorithms for time series forecastingAutomatic algorithms for time series forecasting
Automatic algorithms for time series forecasting
Rob Hyndman
 
Exploring the boundaries of predictability
Exploring the boundaries of predictabilityExploring the boundaries of predictability
Exploring the boundaries of predictability
Rob Hyndman
 
MEFM: An R package for long-term probabilistic forecasting of electricity demand
MEFM: An R package for long-term probabilistic forecasting of electricity demandMEFM: An R package for long-term probabilistic forecasting of electricity demand
MEFM: An R package for long-term probabilistic forecasting of electricity demand
Rob Hyndman
 
Visualization of big time series data
Visualization of big time series dataVisualization of big time series data
Visualization of big time series data
Rob Hyndman
 
Probabilistic forecasting of long-term peak electricity demand
Probabilistic forecasting of long-term peak electricity demandProbabilistic forecasting of long-term peak electricity demand
Probabilistic forecasting of long-term peak electricity demand
Rob Hyndman
 
Visualization and forecasting of big time series data
Visualization and forecasting of big time series dataVisualization and forecasting of big time series data
Visualization and forecasting of big time series data
Rob Hyndman
 
Academia sinica jan-2015
Academia sinica jan-2015Academia sinica jan-2015
Academia sinica jan-2015
Rob Hyndman
 
Automatic time series forecasting
Automatic time series forecastingAutomatic time series forecasting
Automatic time series forecasting
Rob Hyndman
 
Automatic time series forecasting
Automatic time series forecastingAutomatic time series forecasting
Automatic time series forecasting
Rob Hyndman
 
Coherent mortality forecasting using functional time series models
Coherent mortality forecasting using functional time series modelsCoherent mortality forecasting using functional time series models
Coherent mortality forecasting using functional time series modelsRob Hyndman
 
Forecasting using R
Forecasting using RForecasting using R
Forecasting using R
Rob Hyndman
 
SimpleR: tips, tricks & tools
SimpleR: tips, tricks & toolsSimpleR: tips, tricks & tools
SimpleR: tips, tricks & tools
Rob Hyndman
 
Forecasting without forecasters
Forecasting without forecastersForecasting without forecasters
Forecasting without forecasters
Rob Hyndman
 
Demographic forecasting
Demographic forecastingDemographic forecasting
Demographic forecasting
Rob Hyndman
 
Forecasting electricity demand distributions using a semiparametric additive ...
Forecasting electricity demand distributions using a semiparametric additive ...Forecasting electricity demand distributions using a semiparametric additive ...
Forecasting electricity demand distributions using a semiparametric additive ...
Rob Hyndman
 
Advances in automatic time series forecasting
Advances in automatic time series forecastingAdvances in automatic time series forecasting
Advances in automatic time series forecasting
Rob Hyndman
 
FPP 1. Getting started
FPP 1. Getting startedFPP 1. Getting started
FPP 1. Getting started
Rob Hyndman
 

More from Rob Hyndman (19)

Exploring the feature space of large collections of time series
Exploring the feature space of large collections of time seriesExploring the feature space of large collections of time series
Exploring the feature space of large collections of time series
 
Automatic algorithms for time series forecasting
Automatic algorithms for time series forecastingAutomatic algorithms for time series forecasting
Automatic algorithms for time series forecasting
 
Exploring the boundaries of predictability
Exploring the boundaries of predictabilityExploring the boundaries of predictability
Exploring the boundaries of predictability
 
MEFM: An R package for long-term probabilistic forecasting of electricity demand
MEFM: An R package for long-term probabilistic forecasting of electricity demandMEFM: An R package for long-term probabilistic forecasting of electricity demand
MEFM: An R package for long-term probabilistic forecasting of electricity demand
 
Visualization of big time series data
Visualization of big time series dataVisualization of big time series data
Visualization of big time series data
 
Probabilistic forecasting of long-term peak electricity demand
Probabilistic forecasting of long-term peak electricity demandProbabilistic forecasting of long-term peak electricity demand
Probabilistic forecasting of long-term peak electricity demand
 
Visualization and forecasting of big time series data
Visualization and forecasting of big time series dataVisualization and forecasting of big time series data
Visualization and forecasting of big time series data
 
Academia sinica jan-2015
Academia sinica jan-2015Academia sinica jan-2015
Academia sinica jan-2015
 
Automatic time series forecasting
Automatic time series forecastingAutomatic time series forecasting
Automatic time series forecasting
 
Automatic time series forecasting
Automatic time series forecastingAutomatic time series forecasting
Automatic time series forecasting
 
Coherent mortality forecasting using functional time series models
Coherent mortality forecasting using functional time series modelsCoherent mortality forecasting using functional time series models
Coherent mortality forecasting using functional time series models
 
Forecasting using R
Forecasting using RForecasting using R
Forecasting using R
 
SimpleR: tips, tricks & tools
SimpleR: tips, tricks & toolsSimpleR: tips, tricks & tools
SimpleR: tips, tricks & tools
 
Forecasting without forecasters
Forecasting without forecastersForecasting without forecasters
Forecasting without forecasters
 
Ysc2013
Ysc2013Ysc2013
Ysc2013
 
Demographic forecasting
Demographic forecastingDemographic forecasting
Demographic forecasting
 
Forecasting electricity demand distributions using a semiparametric additive ...
Forecasting electricity demand distributions using a semiparametric additive ...Forecasting electricity demand distributions using a semiparametric additive ...
Forecasting electricity demand distributions using a semiparametric additive ...
 
Advances in automatic time series forecasting
Advances in automatic time series forecastingAdvances in automatic time series forecasting
Advances in automatic time series forecasting
 
FPP 1. Getting started
FPP 1. Getting startedFPP 1. Getting started
FPP 1. Getting started
 

Recently uploaded

Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 

Recently uploaded (20)

Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 

R tools for hierarchical time series

  • 1. Total A AA AB AC B BA BB BC C CA CB CC 1 Rob J Hyndman tools for hierarchical time series
  • 2. Introduction Total A AA AB AC B BA BB BC C CA CB CC Examples Manufacturing product hierarchies Pharmaceutical sales Net labour turnover hts: R tools for hierarchical time series 2
  • 3. Introduction Total A AA AB AC B BA BB BC C CA CB CC Examples Manufacturing product hierarchies Pharmaceutical sales Net labour turnover hts: R tools for hierarchical time series 2
  • 4. Introduction Total A AA AB AC B BA BB BC C CA CB CC Examples Manufacturing product hierarchies Pharmaceutical sales Net labour turnover hts: R tools for hierarchical time series 2
  • 5. Introduction Total A AA AB AC B BA BB BC C CA CB CC Examples Manufacturing product hierarchies Pharmaceutical sales Net labour turnover hts: R tools for hierarchical time series 2
  • 6. Hierarchical/grouped time series A hierarchical time series is a collection of several time series that are linked together in a hierarchical structure. Example: Pharmaceutical products are organized in a hierarchy under the Anatomical Therapeutic Chemical (ATC) Classification System. A grouped time series is a collection of time series that are aggregated in a number of non-hierarchical ways. Example: daily numbers of calls to HP call centres are grouped by product type and location of call centre. hts: R tools for hierarchical time series 3
  • 7. Hierarchical/grouped time series A hierarchical time series is a collection of several time series that are linked together in a hierarchical structure. Example: Pharmaceutical products are organized in a hierarchy under the Anatomical Therapeutic Chemical (ATC) Classification System. A grouped time series is a collection of time series that are aggregated in a number of non-hierarchical ways. Example: daily numbers of calls to HP call centres are grouped by product type and location of call centre. hts: R tools for hierarchical time series 3
  • 8. Hierarchical/grouped time series A hierarchical time series is a collection of several time series that are linked together in a hierarchical structure. Example: Pharmaceutical products are organized in a hierarchy under the Anatomical Therapeutic Chemical (ATC) Classification System. A grouped time series is a collection of time series that are aggregated in a number of non-hierarchical ways. Example: daily numbers of calls to HP call centres are grouped by product type and location of call centre. hts: R tools for hierarchical time series 3
  • 9. Hierarchical/grouped time series A hierarchical time series is a collection of several time series that are linked together in a hierarchical structure. Example: Pharmaceutical products are organized in a hierarchy under the Anatomical Therapeutic Chemical (ATC) Classification System. A grouped time series is a collection of time series that are aggregated in a number of non-hierarchical ways. Example: daily numbers of calls to HP call centres are grouped by product type and location of call centre. hts: R tools for hierarchical time series 3
  • 10. Hierarchical/grouped time series Forecasts should be “aggregate consistent”, unbiased, minimum variance. Existing methods: ¢ Bottom-up ¢ Top-down ¢ Middle-out How to compute forecast intervals? Most research is concerned about relative performance of existing methods. There is no research on how to deal with forecasting grouped time series. hts: R tools for hierarchical time series 4
  • 11. Hierarchical/grouped time series Forecasts should be “aggregate consistent”, unbiased, minimum variance. Existing methods: ¢ Bottom-up ¢ Top-down ¢ Middle-out How to compute forecast intervals? Most research is concerned about relative performance of existing methods. There is no research on how to deal with forecasting grouped time series. hts: R tools for hierarchical time series 4
  • 12. Hierarchical/grouped time series Forecasts should be “aggregate consistent”, unbiased, minimum variance. Existing methods: ¢ Bottom-up ¢ Top-down ¢ Middle-out How to compute forecast intervals? Most research is concerned about relative performance of existing methods. There is no research on how to deal with forecasting grouped time series. hts: R tools for hierarchical time series 4
  • 13. Hierarchical/grouped time series Forecasts should be “aggregate consistent”, unbiased, minimum variance. Existing methods: ¢ Bottom-up ¢ Top-down ¢ Middle-out How to compute forecast intervals? Most research is concerned about relative performance of existing methods. There is no research on how to deal with forecasting grouped time series. hts: R tools for hierarchical time series 4
  • 14. Hierarchical/grouped time series Forecasts should be “aggregate consistent”, unbiased, minimum variance. Existing methods: ¢ Bottom-up ¢ Top-down ¢ Middle-out How to compute forecast intervals? Most research is concerned about relative performance of existing methods. There is no research on how to deal with forecasting grouped time series. hts: R tools for hierarchical time series 4
  • 15. Hierarchical/grouped time series Forecasts should be “aggregate consistent”, unbiased, minimum variance. Existing methods: ¢ Bottom-up ¢ Top-down ¢ Middle-out How to compute forecast intervals? Most research is concerned about relative performance of existing methods. There is no research on how to deal with forecasting grouped time series. hts: R tools for hierarchical time series 4
  • 16. Hierarchical/grouped time series Forecasts should be “aggregate consistent”, unbiased, minimum variance. Existing methods: ¢ Bottom-up ¢ Top-down ¢ Middle-out How to compute forecast intervals? Most research is concerned about relative performance of existing methods. There is no research on how to deal with forecasting grouped time series. hts: R tools for hierarchical time series 4
  • 17. Hierarchical/grouped time series Forecasts should be “aggregate consistent”, unbiased, minimum variance. Existing methods: ¢ Bottom-up ¢ Top-down ¢ Middle-out How to compute forecast intervals? Most research is concerned about relative performance of existing methods. There is no research on how to deal with forecasting grouped time series. hts: R tools for hierarchical time series 4
  • 18. Hierarchical data Total A B C hts: R tools for hierarchical time series 5 Yt : observed aggregate of all series at time t. YX,t : observation on series X at time t. Bt : vector of all series at bottom level in time t.
  • 19. Hierarchical data Total A B C hts: R tools for hierarchical time series 5 Yt : observed aggregate of all series at time t. YX,t : observation on series X at time t. Bt : vector of all series at bottom level in time t.
  • 20. Hierarchical data Total A B C Yt = [Yt, YA,t, YB,t, YC,t] =     1 1 1 1 0 0 0 1 0 0 0 1       YA,t YB,t YC,t   hts: R tools for hierarchical time series 5 Yt : observed aggregate of all series at time t. YX,t : observation on series X at time t. Bt : vector of all series at bottom level in time t.
  • 21. Hierarchical data Total A B C Yt = [Yt, YA,t, YB,t, YC,t] =     1 1 1 1 0 0 0 1 0 0 0 1     S   YA,t YB,t YC,t   hts: R tools for hierarchical time series 5 Yt : observed aggregate of all series at time t. YX,t : observation on series X at time t. Bt : vector of all series at bottom level in time t.
  • 22. Hierarchical data Total A B C Yt = [Yt, YA,t, YB,t, YC,t] =     1 1 1 1 0 0 0 1 0 0 0 1     S   YA,t YB,t YC,t   Bt hts: R tools for hierarchical time series 5 Yt : observed aggregate of all series at time t. YX,t : observation on series X at time t. Bt : vector of all series at bottom level in time t.
  • 23. Hierarchical data Total A B C Yt = [Yt, YA,t, YB,t, YC,t] =     1 1 1 1 0 0 0 1 0 0 0 1     S   YA,t YB,t YC,t   Bt Yt = SBt hts: R tools for hierarchical time series 5 Yt : observed aggregate of all series at time t. YX,t : observation on series X at time t. Bt : vector of all series at bottom level in time t.
  • 24. Hierarchical data Total A AX AY AZ B BX BY BZ C CX CY CZ Yt =             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             =             1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1             S        YAX,t YAY,t YAZ,t YBX,t YBY,t YBZ,t YCX,t YCY,t YCZ,t        Bt hts: R tools for hierarchical time series 6
  • 25. Hierarchical data Total A AX AY AZ B BX BY BZ C CX CY CZ Yt =             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             =             1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1             S        YAX,t YAY,t YAZ,t YBX,t YBY,t YBZ,t YCX,t YCY,t YCZ,t        Bt hts: R tools for hierarchical time series 6
  • 26. Hierarchical data Total A AX AY AZ B BX BY BZ C CX CY CZ Yt =             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             =             1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1             S        YAX,t YAY,t YAZ,t YBX,t YBY,t YBZ,t YCX,t YCY,t YCZ,t        Bt hts: R tools for hierarchical time series 6 Yt = SBt
  • 27. Grouped data Total A AX AY B BX BY Total X AX BX Y AY BY Yt =              Yt YA,t YB,t YX,t YY,t YAX,t YAY,t YBX,t YBY,t              =              1 1 1 1 1 1 0 0 0 0 1 1 1 0 1 0 0 1 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1              S    YAX,t YAY,t YBX,t YBY,t    Bt hts: R tools for hierarchical time series 7
  • 28. Grouped data Total A AX AY B BX BY Total X AX BX Y AY BY Yt =              Yt YA,t YB,t YX,t YY,t YAX,t YAY,t YBX,t YBY,t              =              1 1 1 1 1 1 0 0 0 0 1 1 1 0 1 0 0 1 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1              S    YAX,t YAY,t YBX,t YBY,t    Bt hts: R tools for hierarchical time series 7
  • 29. Grouped data Total A AX AY B BX BY Total X AX BX Y AY BY Yt =              Yt YA,t YB,t YX,t YY,t YAX,t YAY,t YBX,t YBY,t              =              1 1 1 1 1 1 0 0 0 0 1 1 1 0 1 0 0 1 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1              S    YAX,t YAY,t YBX,t YBY,t    Bt hts: R tools for hierarchical time series 7 Yt = SBt
  • 30. Forecasts Key idea: forecast reconciliation ¯ Ignore structural constraints and forecast every series of interest independently. ¯ Adjust forecasts to impose constraints. Let ˆYn(h) be vector of initial h-step forecasts, made at time n, stacked in same order as Yt. Yt = SBt . So ˆYn(h) = Sβn(h) + εh . βn(h) = E[Bn+h | Y1, . . . , Yn]. εh has zero mean and covariance Σh. Estimate βn(h) using GLS? hts: R tools for hierarchical time series 8
  • 31. Forecasts Key idea: forecast reconciliation ¯ Ignore structural constraints and forecast every series of interest independently. ¯ Adjust forecasts to impose constraints. Let ˆYn(h) be vector of initial h-step forecasts, made at time n, stacked in same order as Yt. Yt = SBt . So ˆYn(h) = Sβn(h) + εh . βn(h) = E[Bn+h | Y1, . . . , Yn]. εh has zero mean and covariance Σh. Estimate βn(h) using GLS? hts: R tools for hierarchical time series 8
  • 32. Forecasts Key idea: forecast reconciliation ¯ Ignore structural constraints and forecast every series of interest independently. ¯ Adjust forecasts to impose constraints. Let ˆYn(h) be vector of initial h-step forecasts, made at time n, stacked in same order as Yt. Yt = SBt . So ˆYn(h) = Sβn(h) + εh . βn(h) = E[Bn+h | Y1, . . . , Yn]. εh has zero mean and covariance Σh. Estimate βn(h) using GLS? hts: R tools for hierarchical time series 8
  • 33. Forecasts Key idea: forecast reconciliation ¯ Ignore structural constraints and forecast every series of interest independently. ¯ Adjust forecasts to impose constraints. Let ˆYn(h) be vector of initial h-step forecasts, made at time n, stacked in same order as Yt. Yt = SBt . So ˆYn(h) = Sβn(h) + εh . βn(h) = E[Bn+h | Y1, . . . , Yn]. εh has zero mean and covariance Σh. Estimate βn(h) using GLS? hts: R tools for hierarchical time series 8
  • 34. Forecasts Key idea: forecast reconciliation ¯ Ignore structural constraints and forecast every series of interest independently. ¯ Adjust forecasts to impose constraints. Let ˆYn(h) be vector of initial h-step forecasts, made at time n, stacked in same order as Yt. Yt = SBt . So ˆYn(h) = Sβn(h) + εh . βn(h) = E[Bn+h | Y1, . . . , Yn]. εh has zero mean and covariance Σh. Estimate βn(h) using GLS? hts: R tools for hierarchical time series 8
  • 35. Forecasts Key idea: forecast reconciliation ¯ Ignore structural constraints and forecast every series of interest independently. ¯ Adjust forecasts to impose constraints. Let ˆYn(h) be vector of initial h-step forecasts, made at time n, stacked in same order as Yt. Yt = SBt . So ˆYn(h) = Sβn(h) + εh . βn(h) = E[Bn+h | Y1, . . . , Yn]. εh has zero mean and covariance Σh. Estimate βn(h) using GLS? hts: R tools for hierarchical time series 8
  • 36. Forecasts Key idea: forecast reconciliation ¯ Ignore structural constraints and forecast every series of interest independently. ¯ Adjust forecasts to impose constraints. Let ˆYn(h) be vector of initial h-step forecasts, made at time n, stacked in same order as Yt. Yt = SBt . So ˆYn(h) = Sβn(h) + εh . βn(h) = E[Bn+h | Y1, . . . , Yn]. εh has zero mean and covariance Σh. Estimate βn(h) using GLS? hts: R tools for hierarchical time series 8
  • 37. Optimal combination forecasts ˜Yn(h) = S ˆβn(h) = S(S Σ† hS)−1 S Σ† h ˆYn(h) Σ† h is generalized inverse of Σh. Problem: Σh hard to estimate. Solution: Assume εh ≈ SεK,h where εK,h is the forecast error at bottom level. Then Σh ≈ SΩhS where Ωh = Var(εK,h). If Moore-Penrose generalized inverse used, then (S Σ† S)−1 S Σ† = (S S)−1 S . ˜Yn(h) = S(S S)−1 S ˆYn(h) hts: R tools for hierarchical time series 9
  • 38. Optimal combination forecasts ˜Yn(h) = S ˆβn(h) = S(S Σ† hS)−1 S Σ† h ˆYn(h) Initial forecasts Σ† h is generalized inverse of Σh. Problem: Σh hard to estimate. Solution: Assume εh ≈ SεK,h where εK,h is the forecast error at bottom level. Then Σh ≈ SΩhS where Ωh = Var(εK,h). If Moore-Penrose generalized inverse used, then (S Σ† S)−1 S Σ† = (S S)−1 S . ˜Yn(h) = S(S S)−1 S ˆYn(h) hts: R tools for hierarchical time series 9
  • 39. Optimal combination forecasts ˜Yn(h) = S ˆβn(h) = S(S Σ† hS)−1 S Σ† h ˆYn(h) Revised forecasts Initial forecasts Σ† h is generalized inverse of Σh. Problem: Σh hard to estimate. Solution: Assume εh ≈ SεK,h where εK,h is the forecast error at bottom level. Then Σh ≈ SΩhS where Ωh = Var(εK,h). If Moore-Penrose generalized inverse used, then (S Σ† S)−1 S Σ† = (S S)−1 S . ˜Yn(h) = S(S S)−1 S ˆYn(h) hts: R tools for hierarchical time series 9
  • 40. Optimal combination forecasts ˜Yn(h) = S ˆβn(h) = S(S Σ† hS)−1 S Σ† h ˆYn(h) Revised forecasts Initial forecasts Σ† h is generalized inverse of Σh. Problem: Σh hard to estimate. Solution: Assume εh ≈ SεK,h where εK,h is the forecast error at bottom level. Then Σh ≈ SΩhS where Ωh = Var(εK,h). If Moore-Penrose generalized inverse used, then (S Σ† S)−1 S Σ† = (S S)−1 S . ˜Yn(h) = S(S S)−1 S ˆYn(h) hts: R tools for hierarchical time series 9
  • 41. Optimal combination forecasts ˜Yn(h) = S ˆβn(h) = S(S Σ† hS)−1 S Σ† h ˆYn(h) Revised forecasts Initial forecasts Σ† h is generalized inverse of Σh. Problem: Σh hard to estimate. Solution: Assume εh ≈ SεK,h where εK,h is the forecast error at bottom level. Then Σh ≈ SΩhS where Ωh = Var(εK,h). If Moore-Penrose generalized inverse used, then (S Σ† S)−1 S Σ† = (S S)−1 S . ˜Yn(h) = S(S S)−1 S ˆYn(h) hts: R tools for hierarchical time series 9
  • 42. Optimal combination forecasts ˜Yn(h) = S ˆβn(h) = S(S Σ† hS)−1 S Σ† h ˆYn(h) Revised forecasts Initial forecasts Σ† h is generalized inverse of Σh. Problem: Σh hard to estimate. Solution: Assume εh ≈ SεK,h where εK,h is the forecast error at bottom level. Then Σh ≈ SΩhS where Ωh = Var(εK,h). If Moore-Penrose generalized inverse used, then (S Σ† S)−1 S Σ† = (S S)−1 S . ˜Yn(h) = S(S S)−1 S ˆYn(h) hts: R tools for hierarchical time series 9
  • 43. Optimal combination forecasts ˜Yn(h) = S ˆβn(h) = S(S Σ† hS)−1 S Σ† h ˆYn(h) Revised forecasts Initial forecasts Σ† h is generalized inverse of Σh. Problem: Σh hard to estimate. Solution: Assume εh ≈ SεK,h where εK,h is the forecast error at bottom level. Then Σh ≈ SΩhS where Ωh = Var(εK,h). If Moore-Penrose generalized inverse used, then (S Σ† S)−1 S Σ† = (S S)−1 S . ˜Yn(h) = S(S S)−1 S ˆYn(h) hts: R tools for hierarchical time series 9
  • 44. Optimal combination forecasts ˜Yn(h) = S ˆβn(h) = S(S Σ† hS)−1 S Σ† h ˆYn(h) Revised forecasts Initial forecasts Σ† h is generalized inverse of Σh. Problem: Σh hard to estimate. Solution: Assume εh ≈ SεK,h where εK,h is the forecast error at bottom level. Then Σh ≈ SΩhS where Ωh = Var(εK,h). If Moore-Penrose generalized inverse used, then (S Σ† S)−1 S Σ† = (S S)−1 S . ˜Yn(h) = S(S S)−1 S ˆYn(h) hts: R tools for hierarchical time series 9
  • 45. Optimal combination forecasts ˜Yn(h) = S ˆβn(h) = S(S Σ† hS)−1 S Σ† h ˆYn(h) Revised forecasts Initial forecasts Σ† h is generalized inverse of Σh. Problem: Σh hard to estimate. Solution: Assume εh ≈ SεK,h where εK,h is the forecast error at bottom level. Then Σh ≈ SΩhS where Ωh = Var(εK,h). If Moore-Penrose generalized inverse used, then (S Σ† S)−1 S Σ† = (S S)−1 S . ˜Yn(h) = S(S S)−1 S ˆYn(h) hts: R tools for hierarchical time series 9
  • 46. Optimal combination forecasts ˜Yn(h) = S ˆβn(h) = S(S Σ† hS)−1 S Σ† h ˆYn(h) Revised forecasts Initial forecasts Σ† h is generalized inverse of Σh. Problem: Σh hard to estimate. Solution: Assume εh ≈ SεK,h where εK,h is the forecast error at bottom level. Then Σh ≈ SΩhS where Ωh = Var(εK,h). If Moore-Penrose generalized inverse used, then (S Σ† S)−1 S Σ† = (S S)−1 S . ˜Yn(h) = S(S S)−1 S ˆYn(h) hts: R tools for hierarchical time series 9
  • 47. Optimal combination forecasts ˜Yn(h) = S(S S)−1 S ˆYn(h) GLS = OLS. Optimal weighted average of initial forecasts. Optimal reconciliation weights are S(S S)−1 S . Weights are independent of the data and of the covariance structure of the hierarchy! hts: R tools for hierarchical time series 10
  • 48. Optimal combination forecasts ˜Yn(h) = S(S S)−1 S ˆYn(h) GLS = OLS. Optimal weighted average of initial forecasts. Optimal reconciliation weights are S(S S)−1 S . Weights are independent of the data and of the covariance structure of the hierarchy! hts: R tools for hierarchical time series 10
  • 49. Optimal combination forecasts ˜Yn(h) = S(S S)−1 S ˆYn(h) GLS = OLS. Optimal weighted average of initial forecasts. Optimal reconciliation weights are S(S S)−1 S . Weights are independent of the data and of the covariance structure of the hierarchy! hts: R tools for hierarchical time series 10
  • 50. Optimal combination forecasts ˜Yn(h) = S(S S)−1 S ˆYn(h) GLS = OLS. Optimal weighted average of initial forecasts. Optimal reconciliation weights are S(S S)−1 S . Weights are independent of the data and of the covariance structure of the hierarchy! hts: R tools for hierarchical time series 10
  • 51. Optimal combination forecasts Total A AA AB AC B BA BB BC C CA CB CC Weights: S(S S)−1 S =                       0.69 0.23 0.23 0.23 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.23 0.58 −0.17 −0.17 0.19 0.19 0.19 −0.06 −0.06 −0.06 −0.06 −0.06 −0.06 0.23 −0.17 0.58 −0.17 −0.06 −0.06 −0.06 0.19 0.19 0.19 −0.06 −0.06 −0.06 0.23 −0.17 −0.17 0.58 −0.06 −0.06 −0.06 −0.06 −0.06 −0.06 0.19 0.19 0.19 0.08 0.19 −0.06 −0.06 0.73 −0.27 −0.27 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 0.08 0.19 −0.06 −0.06 −0.27 0.73 −0.27 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 0.08 0.19 −0.06 −0.06 −0.27 −0.27 0.73 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 0.08 −0.06 0.19 −0.06 −0.02 −0.02 −0.02 0.73 −0.27 −0.27 −0.02 −0.02 −0.02 0.08 −0.06 0.19 −0.06 −0.02 −0.02 −0.02 −0.27 0.73 −0.27 −0.02 −0.02 −0.02 0.08 −0.06 0.19 −0.06 −0.02 −0.02 −0.02 −0.27 −0.27 0.73 −0.02 −0.02 −0.02 0.08 −0.06 −0.06 0.19 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 0.73 −0.27 −0.27 0.08 −0.06 −0.06 0.19 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 −0.27 0.73 −0.27 0.08 −0.06 −0.06 0.19 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 −0.27 −0.27 0.73                       hts: R tools for hierarchical time series 11
  • 52. Optimal combination forecasts Total A AA AB AC B BA BB BC C CA CB CC Weights: S(S S)−1 S =                       0.69 0.23 0.23 0.23 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.23 0.58 −0.17 −0.17 0.19 0.19 0.19 −0.06 −0.06 −0.06 −0.06 −0.06 −0.06 0.23 −0.17 0.58 −0.17 −0.06 −0.06 −0.06 0.19 0.19 0.19 −0.06 −0.06 −0.06 0.23 −0.17 −0.17 0.58 −0.06 −0.06 −0.06 −0.06 −0.06 −0.06 0.19 0.19 0.19 0.08 0.19 −0.06 −0.06 0.73 −0.27 −0.27 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 0.08 0.19 −0.06 −0.06 −0.27 0.73 −0.27 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 0.08 0.19 −0.06 −0.06 −0.27 −0.27 0.73 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 0.08 −0.06 0.19 −0.06 −0.02 −0.02 −0.02 0.73 −0.27 −0.27 −0.02 −0.02 −0.02 0.08 −0.06 0.19 −0.06 −0.02 −0.02 −0.02 −0.27 0.73 −0.27 −0.02 −0.02 −0.02 0.08 −0.06 0.19 −0.06 −0.02 −0.02 −0.02 −0.27 −0.27 0.73 −0.02 −0.02 −0.02 0.08 −0.06 −0.06 0.19 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 0.73 −0.27 −0.27 0.08 −0.06 −0.06 0.19 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 −0.27 0.73 −0.27 0.08 −0.06 −0.06 0.19 −0.02 −0.02 −0.02 −0.02 −0.02 −0.02 −0.27 −0.27 0.73                       hts: R tools for hierarchical time series 11
  • 53. Features Forget “bottom up” or “top down”. This approach combines all forecasts optimally. Method outperforms bottom-up and top-down, especially for middle levels. Covariates can be included in initial forecasts. Adjustments can be made to initial forecasts at any level. Very simple and flexible method. Can work with any hierarchical or grouped time series. Conceptually easy to implement: OLS on base forecasts. hts: R tools for hierarchical time series 12
  • 54. Features Forget “bottom up” or “top down”. This approach combines all forecasts optimally. Method outperforms bottom-up and top-down, especially for middle levels. Covariates can be included in initial forecasts. Adjustments can be made to initial forecasts at any level. Very simple and flexible method. Can work with any hierarchical or grouped time series. Conceptually easy to implement: OLS on base forecasts. hts: R tools for hierarchical time series 12
  • 55. Features Forget “bottom up” or “top down”. This approach combines all forecasts optimally. Method outperforms bottom-up and top-down, especially for middle levels. Covariates can be included in initial forecasts. Adjustments can be made to initial forecasts at any level. Very simple and flexible method. Can work with any hierarchical or grouped time series. Conceptually easy to implement: OLS on base forecasts. hts: R tools for hierarchical time series 12
  • 56. Features Forget “bottom up” or “top down”. This approach combines all forecasts optimally. Method outperforms bottom-up and top-down, especially for middle levels. Covariates can be included in initial forecasts. Adjustments can be made to initial forecasts at any level. Very simple and flexible method. Can work with any hierarchical or grouped time series. Conceptually easy to implement: OLS on base forecasts. hts: R tools for hierarchical time series 12
  • 57. Features Forget “bottom up” or “top down”. This approach combines all forecasts optimally. Method outperforms bottom-up and top-down, especially for middle levels. Covariates can be included in initial forecasts. Adjustments can be made to initial forecasts at any level. Very simple and flexible method. Can work with any hierarchical or grouped time series. Conceptually easy to implement: OLS on base forecasts. hts: R tools for hierarchical time series 12
  • 58. Features Forget “bottom up” or “top down”. This approach combines all forecasts optimally. Method outperforms bottom-up and top-down, especially for middle levels. Covariates can be included in initial forecasts. Adjustments can be made to initial forecasts at any level. Very simple and flexible method. Can work with any hierarchical or grouped time series. Conceptually easy to implement: OLS on base forecasts. hts: R tools for hierarchical time series 12
  • 59. Challenges Computational difficulties in big hierarchies due to size of the S matrix and non-singular behavior of (S S). Need to estimate covariance matrix to produce prediction intervals. hts: R tools for hierarchical time series 13
  • 60. Challenges Computational difficulties in big hierarchies due to size of the S matrix and non-singular behavior of (S S). Need to estimate covariance matrix to produce prediction intervals. hts: R tools for hierarchical time series 13
  • 61. hts package for R hts: R tools for hierarchical time series 14 hts: Hierarchical and grouped time series Methods for analysing and forecasting hierarchical and grouped time series Version: 3.01 Depends: forecast Imports: SparseM Published: 2013-05-07 Author: Rob J Hyndman, Roman A Ahmed, and Han Lin Shang Maintainer: Rob J Hyndman <Rob.Hyndman at monash.edu> License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
  • 62. Example using R library(hts) # bts is a matrix containing the bottom level time series # g describes the grouping/hierarchical structure y <- hts(bts, g=c(1,1,2,2)) hts: R tools for hierarchical time series 15
  • 63. Example using R library(hts) # bts is a matrix containing the bottom level time series # g describes the grouping/hierarchical structure y <- hts(bts, g=c(1,1,2,2)) hts: R tools for hierarchical time series 15 Total A AX AY B BX BY
  • 64. Example using R library(hts) # bts is a matrix containing the bottom level time series # g describes the grouping/hierarchical structure y <- hts(bts, g=c(1,1,2,2)) # Forecast 10-step-ahead using optimal combination method # ETS used for each series by default fc <- forecast(y, h=10) hts: R tools for hierarchical time series 16
  • 65. Example using R library(hts) # bts is a matrix containing the bottom level time series # g describes the grouping/hierarchical structure y <- hts(bts, g=c(1,1,2,2)) # Forecast 10-step-ahead using optimal combination method # ETS used for each series by default fc <- forecast(y, h=10) # Select your own methods ally <- allts(y) allf <- matrix(, nrow=10, ncol=ncol(ally)) for(i in 1:ncol(ally)) allf[,i] <- mymethod(ally[,i], h=10) allf <- ts(allf, start=2004) # Reconcile forecasts so they add up fc2 <- combinef(allf, Smatrix(y)) hts: R tools for hierarchical time series 17
  • 66. hts function Usage hts(y, g) gts(y, g, hierarchical=FALSE) Arguments y Multivariate time series containing the bot- tom level series g Group matrix indicating the group structure, with one column for each series when com- pletely disaggregated, and one row for each grouping of the time series. hierarchical Indicates if the grouping matrix should be treated as hierarchical. Details hts is simply a wrapper for gts(y,g,TRUE). Both return an object of class gts. hts: R tools for hierarchical time series 18
  • 67. forecast.gts function Usage forecast(object, h, method = c("comb", "bu", "mo", "tdgsf", "tdgsa", "tdfp", "all"), fmethod = c("ets", "rw", "arima"), level, positive = FALSE, xreg = NULL, newxreg = NULL, ...) Arguments object Hierarchical time series object of class gts. h Forecast horizon method Method for distributing forecasts within the hierarchy. fmethod Forecasting method to use level Level used for "middle-out" method (when method="mo") positive If TRUE, forecasts are forced to be strictly positive xreg When fmethod = "arima", a vector or matrix of external re- gressors, which must have the same number of rows as the original univariate time series newxreg When fmethod = "arima", a vector or matrix of external re- gressors, which must have the same number of rows as the original univariate time series ... Other arguments passing to ets or auto.arima hts: R tools for hierarchical time series 19
  • 68. Utility functions allts(y) Returns all series in the hierarchy Smatrix(y) Returns the summing matrix combinef(f) Combines initial forecasts optimally. hts: R tools for hierarchical time series 20
  • 69. More information hts: R tools for hierarchical time series 21 Vignette on CRAN
  • 70. References RJ Hyndman, RA Ahmed, G Athanasopoulos, and HL Shang (2011). “Optimal combination forecasts for hierarchical time series”. Computational Statistics and Data Analysis 55(9), 2579–2589 RJ Hyndman, RA Ahmed, and HL Shang (2013). hts: Hierarchical time series. cran.r-project.org/package=hts. RJ Hyndman and G Athanasopoulos (2013). Forecasting: principles and practice. OTexts. OTexts.com/fpp/. hts: R tools for hierarchical time series 22