SlideShare une entreprise Scribd logo
1  sur  70
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

Contenu connexe

Tendances

Topic 1.4: Randomized Algorithms
Topic 1.4: Randomized AlgorithmsTopic 1.4: Randomized Algorithms
Topic 1.4: Randomized AlgorithmsKM Bappi
 
Brief Introduction to Deep Learning + Solving XOR using ANNs
Brief Introduction to Deep Learning + Solving XOR using ANNsBrief Introduction to Deep Learning + Solving XOR using ANNs
Brief Introduction to Deep Learning + Solving XOR using ANNsAhmed Gad
 
An overview of gradient descent optimization algorithms
An overview of gradient descent optimization algorithms An overview of gradient descent optimization algorithms
An overview of gradient descent optimization algorithms Hakky St
 
Search problems in Artificial Intelligence
Search problems in Artificial IntelligenceSearch problems in Artificial Intelligence
Search problems in Artificial Intelligenceananth
 
Optics ordering points to identify the clustering structure
Optics ordering points to identify the clustering structureOptics ordering points to identify the clustering structure
Optics ordering points to identify the clustering structureRajesh Piryani
 
Pythonのシグナル処理
Pythonのシグナル処理Pythonのシグナル処理
Pythonのシグナル処理Atsuo Ishimoto
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sortMadhu Bala
 
Union find(素集合データ構造)
Union find(素集合データ構造)Union find(素集合データ構造)
Union find(素集合データ構造)AtCoder Inc.
 
Skip lists (Advance Data structure)
Skip lists (Advance Data structure)Skip lists (Advance Data structure)
Skip lists (Advance Data structure)Shubham Shukla
 
[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習
[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習
[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習台灣資料科學年會
 
K mean-clustering algorithm
K mean-clustering algorithmK mean-clustering algorithm
K mean-clustering algorithmparry prabhu
 
String Matching Finite Automata & KMP Algorithm.
String Matching Finite Automata & KMP Algorithm.String Matching Finite Automata & KMP Algorithm.
String Matching Finite Automata & KMP Algorithm.Malek Sumaiya
 
Randomizing quicksort algorith with example
Randomizing quicksort algorith with exampleRandomizing quicksort algorith with example
Randomizing quicksort algorith with examplemaamir farooq
 

Tendances (20)

Topic 1.4: Randomized Algorithms
Topic 1.4: Randomized AlgorithmsTopic 1.4: Randomized Algorithms
Topic 1.4: Randomized Algorithms
 
Brief Introduction to Deep Learning + Solving XOR using ANNs
Brief Introduction to Deep Learning + Solving XOR using ANNsBrief Introduction to Deep Learning + Solving XOR using ANNs
Brief Introduction to Deep Learning + Solving XOR using ANNs
 
An overview of gradient descent optimization algorithms
An overview of gradient descent optimization algorithms An overview of gradient descent optimization algorithms
An overview of gradient descent optimization algorithms
 
Search problems in Artificial Intelligence
Search problems in Artificial IntelligenceSearch problems in Artificial Intelligence
Search problems in Artificial Intelligence
 
Optics ordering points to identify the clustering structure
Optics ordering points to identify the clustering structureOptics ordering points to identify the clustering structure
Optics ordering points to identify the clustering structure
 
Greedy algorithm
Greedy algorithmGreedy algorithm
Greedy algorithm
 
Pythonのシグナル処理
Pythonのシグナル処理Pythonのシグナル処理
Pythonのシグナル処理
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
 
Union find(素集合データ構造)
Union find(素集合データ構造)Union find(素集合データ構造)
Union find(素集合データ構造)
 
Merge sort and quick sort
Merge sort and quick sortMerge sort and quick sort
Merge sort and quick sort
 
Tsp branch and bound
Tsp branch and boundTsp branch and bound
Tsp branch and bound
 
Skip lists (Advance Data structure)
Skip lists (Advance Data structure)Skip lists (Advance Data structure)
Skip lists (Advance Data structure)
 
Slr parser
Slr parserSlr parser
Slr parser
 
Ant colony algorithm
Ant colony algorithmAnt colony algorithm
Ant colony algorithm
 
[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習
[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習
[DSC 2016] 系列活動:李宏毅 / 一天搞懂深度學習
 
Empirical analysis
Empirical analysisEmpirical analysis
Empirical analysis
 
K mean-clustering algorithm
K mean-clustering algorithmK mean-clustering algorithm
K mean-clustering algorithm
 
String Matching Finite Automata & KMP Algorithm.
String Matching Finite Automata & KMP Algorithm.String Matching Finite Automata & KMP Algorithm.
String Matching Finite Automata & KMP Algorithm.
 
AI local search
AI local searchAI local search
AI local search
 
Randomizing quicksort algorith with example
Randomizing quicksort algorith with exampleRandomizing quicksort algorith with example
Randomizing quicksort algorith with example
 

Similaire à R tools for hierarchical time series

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).pptxOyebayo 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 2013AlsalheenAlraied
 
Iso 9001 requirements
Iso 9001 requirementsIso 9001 requirements
Iso 9001 requirementsdaretjon
 

Similaire à R tools for hierarchical time series (20)

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
 
Iso 9001 requirements
Iso 9001 requirementsIso 9001 requirements
Iso 9001 requirements
 

Plus de 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 seriesRob Hyndman
 
Automatic algorithms for time series forecasting
Automatic algorithms for time series forecastingAutomatic algorithms for time series forecasting
Automatic algorithms for time series forecastingRob Hyndman
 
Exploring the boundaries of predictability
Exploring the boundaries of predictabilityExploring the boundaries of predictability
Exploring the boundaries of predictabilityRob 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 demandRob Hyndman
 
Visualization of big time series data
Visualization of big time series dataVisualization of big time series data
Visualization of big time series dataRob 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 demandRob 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 dataRob Hyndman
 
Academia sinica jan-2015
Academia sinica jan-2015Academia sinica jan-2015
Academia sinica jan-2015Rob Hyndman
 
Automatic time series forecasting
Automatic time series forecastingAutomatic time series forecasting
Automatic time series forecastingRob Hyndman
 
Automatic time series forecasting
Automatic time series forecastingAutomatic time series forecasting
Automatic time series forecastingRob 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 RRob Hyndman
 
SimpleR: tips, tricks & tools
SimpleR: tips, tricks & toolsSimpleR: tips, tricks & tools
SimpleR: tips, tricks & toolsRob Hyndman
 
Forecasting without forecasters
Forecasting without forecastersForecasting without forecasters
Forecasting without forecastersRob Hyndman
 
Demographic forecasting
Demographic forecastingDemographic forecasting
Demographic forecastingRob 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 forecastingRob Hyndman
 
FPP 1. Getting started
FPP 1. Getting startedFPP 1. Getting started
FPP 1. Getting startedRob Hyndman
 

Plus de 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
 

Dernier

Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 

Dernier (20)

Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 

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