Linear Unbiased Forecasts 3 Applica on: Australian tourism 4 Fast computa on tricks 5 hts package for R 6 Temporal hierarchies 7 References Forecas ng large collec ons of related me series Hierarchical and grouped me series 2
Classifica on of Occupa ons 8 major groups 43 sub-major groups 97 minor groups – 359 unit groups * 1023 occupa ons Example: Sta s cian 2 Professionals 22 Business, Human Resource and Marke ng Professionals 224 Informa on and Organisa on Professionals 2241 Actuaries, Mathema cians and Sta s cians 224113 Sta s cian Forecas ng large collec ons of related me series Hierarchical and grouped me series 3
Classifica on of Occupa ons 8 major groups 43 sub-major groups 97 minor groups – 359 unit groups * 1023 occupa ons Example: Sta s cian 2 Professionals 22 Business, Human Resource and Marke ng Professionals 224 Informa on and Organisa on Professionals 2241 Actuaries, Mathema cians and Sta s cians 224113 Sta s cian Forecas ng large collec ons of related me series Hierarchical and grouped me series 3
me series Hierarchical and grouped me series 4 Quarterly data on visitor night from 1998:Q1 – 2013:Q4 From Na onal Visitor Survey, based on annual interviews of 120,000 Australians aged 15+, collected by Tourism Research Australia. Split by 7 states, 27 zones and 76 regions (a geographical hierarchy) Also split by purpose of travel Holiday Visi ng friends and rela ves (VFR) Business Other 304 bo om-level series
series Hierarchical and grouped me series 5 Monthly UK sales data from 2000 – 2014 Provided by a large spectacle manufacturer Split by brand (26), gender (3), price range (6), materials (4), and stores (600) About 1 million bo om-level series
series Hierarchical and grouped me series 5 Monthly UK sales data from 2000 – 2014 Provided by a large spectacle manufacturer Split by brand (26), gender (3), price range (6), materials (4), and stores (600) About 1 million bo om-level series
series Hierarchical and grouped me series 5 Monthly UK sales data from 2000 – 2014 Provided by a large spectacle manufacturer Split by brand (26), gender (3), price range (6), materials (4), and stores (600) About 1 million bo om-level series
series Hierarchical and grouped me series 5 Monthly UK sales data from 2000 – 2014 Provided by a large spectacle manufacturer Split by brand (26), gender (3), price range (6), materials (4), and stores (600) About 1 million bo om-level series
on of several me series that are linked together in a hierarchical structure. Total A AA AB AC B BA BB BC C CA CB CC Examples Labour turnover by occupa on Tourism by state and region Forecas ng large collec ons of related me series Hierarchical and grouped me series 6
on of several me series that are linked together in a hierarchical structure. Total A AA AB AC B BA BB BC C CA CB CC Examples Labour turnover by occupa on Tourism by state and region Forecas ng large collec ons of related me series Hierarchical and grouped me series 6
on of several me series that are linked together in a hierarchical structure. Total A AA AB AC B BA BB BC C CA CB CC Examples Labour turnover by occupa on Tourism by state and region Forecas ng large collec ons of related me series Hierarchical and grouped me series 6
on of me series that can be grouped together in a number of non-hierarchical ways. Total A AX AY B BX BY Total X AX BX Y AY BY Examples Labour turnover by occupa on and state Tourism by region and purpose of travel Spectacle sales by brand, gender, stores, etc. Forecas ng large collec ons of related me series Hierarchical and grouped me series 7
on of me series that can be grouped together in a number of non-hierarchical ways. Total A AX AY B BX BY Total X AX BX Y AY BY Examples Labour turnover by occupa on and state Tourism by region and purpose of travel Spectacle sales by brand, gender, stores, etc. Forecas ng large collec ons of related me series Hierarchical and grouped me series 7
on of me series that can be grouped together in a number of non-hierarchical ways. Total A AX AY B BX BY Total X AX BX Y AY BY Examples Labour turnover by occupa on and state Tourism by region and purpose of travel Spectacle sales by brand, gender, stores, etc. Forecas ng large collec ons of related me series Hierarchical and grouped me series 7
on of me series that can be grouped together in a number of non-hierarchical ways. Total A AX AY B BX BY Total X AX BX Y AY BY Examples Labour turnover by occupa on and state Tourism by region and purpose of travel Spectacle sales by brand, gender, stores, etc. Forecas ng large collec ons of related me series Hierarchical and grouped me series 7
on using an automa c forecas ng algorithm (e.g., ets, auto.arima, ...) 2 Reconcile the resul ng forecasts so they add up correctly using least squares op miza on (i.e., find closest reconciled forecasts to the original forecasts). 3 This is all available in the hts package in R. Forecas ng large collec ons of related me series Hierarchical and grouped me series 8
on using an automa c forecas ng algorithm (e.g., ets, auto.arima, ...) 2 Reconcile the resul ng forecasts so they add up correctly using least squares op miza on (i.e., find closest reconciled forecasts to the original forecasts). 3 This is all available in the hts package in R. Forecas ng large collec ons of related me series Hierarchical and grouped me series 8
on using an automa c forecas ng algorithm (e.g., ets, auto.arima, ...) 2 Reconcile the resul ng forecasts so they add up correctly using least squares op miza on (i.e., find closest reconciled forecasts to the original forecasts). 3 This is all available in the hts package in R. Forecas ng large collec ons of related me series Hierarchical and grouped me series 8
collec ons of related me series Hierarchical and grouped me series 9 yt : observed aggregate of all series at me t. yX,t : observa on on series X at me t. bt : vector of all series at bo om level in me t.
collec ons of related me series Hierarchical and grouped me series 9 yt : observed aggregate of all series at me t. yX,t : observa on on series X at me t. bt : vector of all series at bo om level in me t.
, yA,t , yB,t , yC,t ] = 1 1 1 1 0 0 0 1 0 0 0 1 yA,t yB,t yC,t Forecas ng large collec ons of related me series Hierarchical and grouped me series 9 yt : observed aggregate of all series at me t. yX,t : observa on on series X at me t. bt : vector of all series at bo om level in me t.
, 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 Forecas ng large collec ons of related me series Hierarchical and grouped me series 9 yt : observed aggregate of all series at me t. yX,t : observa on on series X at me t. bt : vector of all series at bo om level in me t.
, 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 Forecas ng large collec ons of related me series Hierarchical and grouped me series 9 yt : observed aggregate of all series at me t. yX,t : observa on on series X at me t. bt : vector of all series at bo om level in me t.
, 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 Forecas ng large collec ons of related me series Hierarchical and grouped me series 9 yt : observed aggregate of all series at me t. yX,t : observa on on series X at me t. bt : vector of all series at bo om level in me t.
series with aggrega on constraints can be wri en as yt = Sbt where yt is a vector of all series at me t bt is a vector of the most disaggregated series at me t S is a “summing matrix” containing the aggrega on constraints. Forecas ng large collec ons of related me series Hierarchical and grouped me series 12
Linear Unbiased Forecasts 3 Applica on: Australian tourism 4 Fast computa on tricks 5 hts package for R 6 Temporal hierarchies 7 References Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 13
of ini al h-step forecasts, made at me n, stacked in same order as yt. (In general, they will not “add up”.) Reconciled forecasts must be of the form: ˜ yn (h) = SPˆ yn (h) for some matrix P. P extracts and combines base forecasts ˆ yn (h) to get bo om-level forecasts. S adds them up Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 14
of ini al h-step forecasts, made at me n, stacked in same order as yt. (In general, they will not “add up”.) Reconciled forecasts must be of the form: ˜ yn (h) = SPˆ yn (h) for some matrix P. P extracts and combines base forecasts ˆ yn (h) to get bo om-level forecasts. S adds them up Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 14
of ini al h-step forecasts, made at me n, stacked in same order as yt. (In general, they will not “add up”.) Reconciled forecasts must be of the form: ˜ yn (h) = SPˆ yn (h) for some matrix P. P extracts and combines base forecasts ˆ yn (h) to get bo om-level forecasts. S adds them up Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 14
of ini al h-step forecasts, made at me n, stacked in same order as yt. (In general, they will not “add up”.) Reconciled forecasts must be of the form: ˜ yn (h) = SPˆ yn (h) for some matrix P. P extracts and combines base forecasts ˆ yn (h) to get bo om-level forecasts. S adds them up Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 14
of ini al h-step forecasts, made at me n, stacked in same order as yt. (In general, they will not “add up”.) Reconciled forecasts must be of the form: ˜ yn (h) = SPˆ yn (h) for some matrix P. P extracts and combines base forecasts ˆ yn (h) to get bo om-level forecasts. S adds them up Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 14
(h) Assume: base forecasts ˆ yn (h) are unbiased: E[ˆ yn (h) | y1 , . . . , yn ] = E[yn+h | y1 , . . . , yn ] Let ˆ bn (h) be bo om level base forecasts with βn (h) = E[ˆ bn (h) | y1 , . . . , yn ]. Then E[ˆ yn (h)] = Sβn (h). We want the reconciled forecasts to be unbiased: E[˜ yn (h)] = SPSβn (h) = Sβn (h). Reconciled forecasts are unbiased iff SPS = S. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 15
(h) Assume: base forecasts ˆ yn (h) are unbiased: E[ˆ yn (h) | y1 , . . . , yn ] = E[yn+h | y1 , . . . , yn ] Let ˆ bn (h) be bo om level base forecasts with βn (h) = E[ˆ bn (h) | y1 , . . . , yn ]. Then E[ˆ yn (h)] = Sβn (h). We want the reconciled forecasts to be unbiased: E[˜ yn (h)] = SPSβn (h) = Sβn (h). Reconciled forecasts are unbiased iff SPS = S. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 15
(h) Assume: base forecasts ˆ yn (h) are unbiased: E[ˆ yn (h) | y1 , . . . , yn ] = E[yn+h | y1 , . . . , yn ] Let ˆ bn (h) be bo om level base forecasts with βn (h) = E[ˆ bn (h) | y1 , . . . , yn ]. Then E[ˆ yn (h)] = Sβn (h). We want the reconciled forecasts to be unbiased: E[˜ yn (h)] = SPSβn (h) = Sβn (h). Reconciled forecasts are unbiased iff SPS = S. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 15
(h) Assume: base forecasts ˆ yn (h) are unbiased: E[ˆ yn (h) | y1 , . . . , yn ] = E[yn+h | y1 , . . . , yn ] Let ˆ bn (h) be bo om level base forecasts with βn (h) = E[ˆ bn (h) | y1 , . . . , yn ]. Then E[ˆ yn (h)] = Sβn (h). We want the reconciled forecasts to be unbiased: E[˜ yn (h)] = SPSβn (h) = Sβn (h). Reconciled forecasts are unbiased iff SPS = S. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 15
(h) Assume: base forecasts ˆ yn (h) are unbiased: E[ˆ yn (h) | y1 , . . . , yn ] = E[yn+h | y1 , . . . , yn ] Let ˆ bn (h) be bo om level base forecasts with βn (h) = E[ˆ bn (h) | y1 , . . . , yn ]. Then E[ˆ yn (h)] = Sβn (h). We want the reconciled forecasts to be unbiased: E[˜ yn (h)] = SPSβn (h) = Sβn (h). Reconciled forecasts are unbiased iff SPS = S. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 15
(h) Assume: base forecasts ˆ yn (h) are unbiased: E[ˆ yn (h) | y1 , . . . , yn ] = E[yn+h | y1 , . . . , yn ] Let ˆ bn (h) be bo om level base forecasts with βn (h) = E[ˆ bn (h) | y1 , . . . , yn ]. Then E[ˆ yn (h)] = Sβn (h). We want the reconciled forecasts to be unbiased: E[˜ yn (h)] = SPSβn (h) = Sβn (h). Reconciled forecasts are unbiased iff SPS = S. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 15
(h) Assume: base forecasts ˆ yn (h) are unbiased: E[ˆ yn (h) | y1 , . . . , yn ] = E[yn+h | y1 , . . . , yn ] Let ˆ bn (h) be bo om level base forecasts with βn (h) = E[ˆ bn (h) | y1 , . . . , yn ]. Then E[ˆ yn (h)] = Sβn (h). We want the reconciled forecasts to be unbiased: E[˜ yn (h)] = SPSβn (h) = Sβn (h). Reconciled forecasts are unbiased iff SPS = S. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 15
(h) Let error variance of h-step base forecasts ˆ yn (h) be Wh = Var[yn+h − ˆ yn (h) | y1 , . . . , yn ] Then the error variance of the corresponding reconciled forecasts is Var[yn+h − ˜ yn (h) | y1 , . . . , yn ] = SPWh P S Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 16
(h) Let error variance of h-step base forecasts ˆ yn (h) be Wh = Var[yn+h − ˆ yn (h) | y1 , . . . , yn ] Then the error variance of the corresponding reconciled forecasts is Var[yn+h − ˜ yn (h) | y1 , . . . , yn ] = SPWh P S Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 16
sfying SPS = S, then min P = trace[SPWh P S ] has solu on P = (S W−1 h S)−1S W−1 h . Var[yn+h − ˜ yn (h) | y1 , . . . , yn ] = (S W−1 h S)−1S Problem: Wh hard to es mate, especially for h > 1. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 17
sfying SPS = S, then min P = trace[SPWh P S ] has solu on P = (S W−1 h S)−1S W−1 h . Var[yn+h − ˜ yn (h) | y1 , . . . , yn ] = (S W−1 h S)−1S Problem: Wh hard to es mate, especially for h > 1. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 17
sfying SPS = S, then min P = trace[SPWh P S ] has solu on P = (S W−1 h S)−1S W−1 h . Var[yn+h − ˜ yn (h) | y1 , . . . , yn ] = (S W−1 h S)−1S Problem: Wh hard to es mate, especially for h > 1. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 17
on 1: OLS Assume Wh ≈ kh I. ˜ yn (h) = S(S S)−1S ˆ yn (h) Reconcilia on does not depend on data Works surprisingly well. S ll need to es mate covariance matrix to produce predic on intervals. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 18 ˜ yn (h) = S(S W−1 h S)−1S W−1 h ˆ yn (h)
on 1: OLS Assume Wh ≈ kh I. ˜ yn (h) = S(S S)−1S ˆ yn (h) Reconcilia on does not depend on data Works surprisingly well. S ll need to es mate covariance matrix to produce predic on intervals. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 18 ˜ yn (h) = S(S W−1 h S)−1S W−1 h ˆ yn (h)
on 1: OLS Assume Wh ≈ kh I. ˜ yn (h) = S(S S)−1S ˆ yn (h) Reconcilia on does not depend on data Works surprisingly well. S ll need to es mate covariance matrix to produce predic on intervals. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 18 ˜ yn (h) = S(S W−1 h S)−1S W−1 h ˆ yn (h)
on 1: OLS Assume Wh ≈ kh I. ˜ yn (h) = S(S S)−1S ˆ yn (h) Reconcilia on does not depend on data Works surprisingly well. S ll need to es mate covariance matrix to produce predic on intervals. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 18 ˜ yn (h) = S(S W−1 h S)−1S W−1 h ˆ yn (h)
on 1: OLS Assume Wh ≈ kh I. ˜ yn (h) = S(S S)−1S ˆ yn (h) Reconcilia on does not depend on data Works surprisingly well. S ll need to es mate covariance matrix to produce predic on intervals. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 18 ˜ yn (h) = S(S W−1 h S)−1S W−1 h ˆ yn (h)
on 1: OLS Assume Wh ≈ kh I. ˜ yn (h) = S(S S)−1S ˆ yn (h) Reconcilia on does not depend on data Works surprisingly well. S ll need to es mate covariance matrix to produce predic on intervals. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 18 ˜ yn (h) = S(S W−1 h S)−1S W−1 h ˆ yn (h)
on 2: WLS Suppose we approximate W1 by its diagonal and assume that Wh = kh W1. Easy to es mate, and places weight where we have best forecasts. S ll need to es mate covariance matrix to produce predic on intervals. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 19 ˜ yn (h) = S(S W−1 h S)−1S W−1 h ˆ yn (h)
on 2: WLS Suppose we approximate W1 by its diagonal and assume that Wh = kh W1. Easy to es mate, and places weight where we have best forecasts. S ll need to es mate covariance matrix to produce predic on intervals. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 19 ˜ yn (h) = S(S W−1 h S)−1S W−1 h ˆ yn (h)
on 2: WLS Suppose we approximate W1 by its diagonal and assume that Wh = kh W1. Easy to es mate, and places weight where we have best forecasts. S ll need to es mate covariance matrix to produce predic on intervals. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 19 ˜ yn (h) = S(S W−1 h S)−1S W−1 h ˆ yn (h)
on 2: WLS Suppose we approximate W1 by its diagonal and assume that Wh = kh W1. Easy to es mate, and places weight where we have best forecasts. S ll need to es mate covariance matrix to produce predic on intervals. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 19 ˜ yn (h) = S(S W−1 h S)−1S W−1 h ˆ yn (h)
on 3: GLS Es mate W1 using shrinkage to the diagonal and assume that Wh = kh W1. Allows for covariances. Difficult to compute for large numbers of me series. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 20 ˜ yn (h) = S(S W−1 h S)−1S W−1 h ˆ yn (h)
on 3: GLS Es mate W1 using shrinkage to the diagonal and assume that Wh = kh W1. Allows for covariances. Difficult to compute for large numbers of me series. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 20 ˜ yn (h) = S(S W−1 h S)−1S W−1 h ˆ yn (h)
on 3: GLS Es mate W1 using shrinkage to the diagonal and assume that Wh = kh W1. Allows for covariances. Difficult to compute for large numbers of me series. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 20 ˜ yn (h) = S(S W−1 h S)−1S W−1 h ˆ yn (h)
on 3: GLS Es mate W1 using shrinkage to the diagonal and assume that Wh = kh W1. Allows for covariances. Difficult to compute for large numbers of me series. Forecas ng large collec ons of related me series BLUF: Best Linear Unbiased Forecasts 20 ˜ yn (h) = S(S W−1 h S)−1S W−1 h ˆ yn (h)
Linear Unbiased Forecasts 3 Applica on: Australian tourism 4 Fast computa on tricks 5 hts package for R 6 Temporal hierarchies 7 References Forecas ng large collec ons of related me series Applica on: Australian tourism 21
series Applica on: Australian tourism 23 Domestic tourism forecasts: Total Year Visitor nights 1998 2000 2002 2004 2006 2008 60000 65000 70000 75000 80000 85000
Linear Unbiased Forecasts 3 Applica on: Australian tourism 4 Fast computa on tricks 5 hts package for R 6 Temporal hierarchies 7 References Forecas ng large collec ons of related me series Fast computa on tricks 26
tree of trees: Total T1 T2 ... TK Then the summing matrix contains k smaller summing matrices: S = 1n1 1n2 · · · 1nK S1 0 · · · 0 0 S2 · · · 0 . . . . . . ... . . . 0 0 · · · SK where 1n is an n-vector of ones and tree Ti has ni terminal nodes. Forecas ng large collec ons of related me series Fast computa on tricks 29
tree of trees: Total T1 T2 ... TK Then the summing matrix contains k smaller summing matrices: S = 1n1 1n2 · · · 1nK S1 0 · · · 0 0 S2 · · · 0 . . . . . . ... . . . 0 0 · · · SK where 1n is an n-vector of ones and tree Ti has ni terminal nodes. Forecas ng large collec ons of related me series Fast computa on tricks 29
S1 Λ1 S1 0 · · · 0 0 S2 Λ2 S2 · · · 0 . . . . . . ... . . . 0 0 · · · SK ΛK SK + λ0 Jn λ0 is the top le element of Λ; Λk is a block of Λ, corresponding to tree Tk; Jn is a matrix of ones; n = k nk. Now apply the Sherman-Morrison formula ... Forecas ng large collec ons of related me series Fast computa on tricks 30
S1 Λ1 S1 0 · · · 0 0 S2 Λ2 S2 · · · 0 . . . . . . ... . . . 0 0 · · · SK ΛK SK + λ0 Jn λ0 is the top le element of Λ; Λk is a block of Λ, corresponding to tree Tk; Jn is a matrix of ones; n = k nk. Now apply the Sherman-Morrison formula ... Forecas ng large collec ons of related me series Fast computa on tricks 30
(S1 Λ1 S1 )−1 0 · · · 0 0 (S2 Λ2 S2 )−1 · · · 0 . . . . . . ... . . . 0 0 · · · (SK ΛK SK )−1 − cS0 S0 can be par oned into K2 blocks, with the (k, ) block (of dimension nk × n ) being (Sk Λk Sk )−1Jnk ,n (S Λ S )−1 Jnk ,n is a nk × n matrix of ones. c−1 = λ−1 0 + k 1nk (Sk Λk Sk )−11nk . Each Sk Λk Sk can be inverted similarly. S Λy can also be computed recursively. Forecas ng large collec ons of related me series Fast computa on tricks 31
(S1 Λ1 S1 )−1 0 · · · 0 0 (S2 Λ2 S2 )−1 · · · 0 . . . . . . ... . . . 0 0 · · · (SK ΛK SK )−1 − cS0 S0 can be par oned into K2 blocks, with the (k, ) block (of dimension nk × n ) being (Sk Λk Sk )−1Jnk ,n (S Λ S )−1 Jnk ,n is a nk × n matrix of ones. c−1 = λ−1 0 + k 1nk (Sk Λk Sk )−11nk . Each Sk Λk Sk can be inverted similarly. S Λy can also be computed recursively. Forecas ng large collec ons of related me series Fast computa on tricks 31 The recursive calcula ons can be done in such a way that we never store any of the large matrices involved.
grouped me series with two groups. When the me series are not strictly hierarchical and have more than two grouping variables: Use sparse matrix storage and arithme c. Use itera ve approxima on for inver ng large sparse matrices. Paige & Saunders (1982) ACM Trans. Math. So ware Forecas ng large collec ons of related me series Fast computa on tricks 32
grouped me series with two groups. When the me series are not strictly hierarchical and have more than two grouping variables: Use sparse matrix storage and arithme c. Use itera ve approxima on for inver ng large sparse matrices. Paige & Saunders (1982) ACM Trans. Math. So ware Forecas ng large collec ons of related me series Fast computa on tricks 32
grouped me series with two groups. When the me series are not strictly hierarchical and have more than two grouping variables: Use sparse matrix storage and arithme c. Use itera ve approxima on for inver ng large sparse matrices. Paige & Saunders (1982) ACM Trans. Math. So ware Forecas ng large collec ons of related me series Fast computa on tricks 32
Linear Unbiased Forecasts 3 Applica on: Australian tourism 4 Fast computa on tricks 5 hts package for R 6 Temporal hierarchies 7 References Forecas ng large collec ons of related me series hts package for R 33
related me series hts package for R 34 hts: Hierarchical and Grouped Time Series Methods for analysing and forecas ng hierarchical and grouped me series Version: 5.0 Depends: R ( 3.0.2), forecast ( 5.0), SparseM, Matrix, matrixcalc Imports: parallel, u ls, methods, graphics, grDevices, stats LinkingTo: Rcpp ( 0.11.0), RcppEigen Suggests: tes hat Published: 2016-04-06 Author: Rob J Hyndman, Earo Wang, Alan Lee, Shanika Wickramasuriya Maintainer: Rob J Hyndman <Rob.Hyndman at monash.edu> BugReports: https://github.com/robjhyndman/hts/issues License: GPL ( 2)
the bottom level time series # nodes describes the hierarchical structure y <- hts(bts, nodes=list(2, c(3,2))) Forecas ng large collec ons of related me series hts package for R 35
the bottom level time series # nodes describes the hierarchical structure y <- hts(bts, nodes=list(2, c(3,2))) Forecas ng large collec ons of related me series hts package for R 35 Total A AX AY AZ B BX BY
the bottom level time series # nodes describes the hierarchical structure y <- hts(bts, nodes=list(2, c(3,2))) # Forecast 10-step-ahead using WLS combination method # ETS used for each series by default fc <- forecast(y, h=10) Forecas ng large collec ons of related me series hts package for R 36
"mo","tdgsa", "tdgsf", "tdfp"), weights = c("wls", "ols", "mint", "nseries"), fmethod = c("ets", "arima", "rw"), algorithms = c("lu", "cg", "chol", "recursive", "slm"), covariance = c("shr", "sam"), positive = FALSE, parallel = FALSE, num.cores = 2, ...) Arguments object Hierarchical me series object of class gts. h Forecast horizon method Method for distribu ng forecasts within the hierarchy. weights Weights used for “op mal combina on” method. When weights = “sd”, it takes account of the standard devia on of forecasts. fmethod Forecas ng method to use algorithm Method for solving regression equa ons positive If TRUE, forecasts are forced to be strictly posi ve parallel If TRUE, allow parallel processing num.cores If parallel = TRUE, specify how many cores are going to be used Forecas ng large collec ons of related me series hts package for R 37
Linear Unbiased Forecasts 3 Applica on: Australian tourism 4 Fast computa on tricks 5 hts package for R 6 Temporal hierarchies 7 References Forecas ng large collec ons of related me series Temporal hierarchies 38
idea: ¯ Forecast series at each available frequency. ¯ Op mally reconcile forecasts within the same year. Forecas ng large collec ons of related me series Temporal hierarchies 39
idea: ¯ Forecast series at each available frequency. ¯ Op mally reconcile forecasts within the same year. Forecas ng large collec ons of related me series Temporal hierarchies 39
M5 M6 Semi-Annual2 Q3 M7 M8 M9 Q4 M10 M11 M12 k = 2, 4, 12 nodes k = 3, 6, 12 nodes Why not k = 2, 3, 4, 6, 12 nodes? Forecas ng large collec ons of related me series Temporal hierarchies 40
FourM2 BiM3 M5 M6 BiM4 M7 M8 FourM3 BiM5 M9 M10 BiM6 M11 M12 k = 2, 4, 12 nodes k = 3, 6, 12 nodes Why not k = 2, 3, 4, 6, 12 nodes? Forecas ng large collec ons of related me series Temporal hierarchies 40
FourM2 BiM3 M5 M6 BiM4 M7 M8 FourM3 BiM5 M9 M10 BiM6 M11 M12 k = 2, 4, 12 nodes k = 3, 6, 12 nodes Why not k = 2, 3, 4, 6, 12 nodes? Forecas ng large collec ons of related me series Temporal hierarchies 40
. , yT, observed at frequency m, we generate aggregate series y[k] j = jk t=1+(j−1)k yt , for j = 1, . . . , T/k k ∈ F(m) = {factors of m}. A single unique hierarchy is only possible when there are no coprime pairs in F(m). Mk = m/k is seasonal period of aggregated series. Forecas ng large collec ons of related me series Temporal hierarchies 42
. , yT, observed at frequency m, we generate aggregate series y[k] j = jk t=1+(j−1)k yt , for j = 1, . . . , T/k k ∈ F(m) = {factors of m}. A single unique hierarchy is only possible when there are no coprime pairs in F(m). Mk = m/k is seasonal period of aggregated series. Forecas ng large collec ons of related me series Temporal hierarchies 42
. , yT, observed at frequency m, we generate aggregate series y[k] j = jk t=1+(j−1)k yt , for j = 1, . . . , T/k k ∈ F(m) = {factors of m}. A single unique hierarchy is only possible when there are no coprime pairs in F(m). Mk = m/k is seasonal period of aggregated series. Forecas ng large collec ons of related me series Temporal hierarchies 42
ΛV: elements equal within aggrega on level. Structural scaling ΛS = diag(S1): elements equal to # nodes at each level. Depends only on seasonal period m. Independent of data and model. Allows forecasts where no errors available. Quarterly example ΛH = diag ˆ σ2 A , ˆ σ2 S1 , ˆ σ2 S2 , ˆ σ2 Q1 , ˆ σ2 Q2 , ˆ σ2 Q3 , ˆ σ2 Q4 ΛV = diag ˆ σ2 A , ˆ σ2 S , ˆ σ2 S , ˆ σ2 Q , ˆ σ2 Q , ˆ σ2 Q , ˆ σ2 Q ΛS = diag 4, 2, 2, 1, 1, 1, 1 Forecas ng large collec ons of related me series Temporal hierarchies 43
ΛV: elements equal within aggrega on level. Structural scaling ΛS = diag(S1): elements equal to # nodes at each level. Depends only on seasonal period m. Independent of data and model. Allows forecasts where no errors available. Quarterly example ΛH = diag ˆ σ2 A , ˆ σ2 S1 , ˆ σ2 S2 , ˆ σ2 Q1 , ˆ σ2 Q2 , ˆ σ2 Q3 , ˆ σ2 Q4 ΛV = diag ˆ σ2 A , ˆ σ2 S , ˆ σ2 S , ˆ σ2 Q , ˆ σ2 Q , ˆ σ2 Q , ˆ σ2 Q ΛS = diag 4, 2, 2, 1, 1, 1, 1 Forecas ng large collec ons of related me series Temporal hierarchies 43
ΛV: elements equal within aggrega on level. Structural scaling ΛS = diag(S1): elements equal to # nodes at each level. Depends only on seasonal period m. Independent of data and model. Allows forecasts where no errors available. Quarterly example ΛH = diag ˆ σ2 A , ˆ σ2 S1 , ˆ σ2 S2 , ˆ σ2 Q1 , ˆ σ2 Q2 , ˆ σ2 Q3 , ˆ σ2 Q4 ΛV = diag ˆ σ2 A , ˆ σ2 S , ˆ σ2 S , ˆ σ2 Q , ˆ σ2 Q , ˆ σ2 Q , ˆ σ2 Q ΛS = diag 4, 2, 2, 1, 1, 1, 1 Forecas ng large collec ons of related me series Temporal hierarchies 43
Major A&E 2 Type 2 Departments — Single Specialty 3 Type 3 Departments — Other A&E/Minor Injury 4 Total A endances 5 Type 1 Departments — Major A&E > 4 hrs 6 Type 2 Departments — Single Specialty > 4 hrs 7 Type 3 Departments — Other A&E/Minor Injury > 4 hrs 8 Total A endances > 4 hrs 9 Emergency Admissions via Type 1 A&E 10 Total Emergency Admissions via A&E 11 Other Emergency Admissions (i.e., not via A&E) 12 Total Emergency Admissions 13 Number of pa ents spending > 4 hrs from decision to admission Forecas ng large collec ons of related me series Temporal hierarchies 45
except the last year Base forecasts using auto.arima(). Reconciled using WLSV. Mean Absolute Scaled Errors for 1, 4 and 13 weeks ahead using a rolling origin. Aggr. Level h Base Reconciled Change Weekly 1 1.6 1.3 −17.2% Weekly 4 1.9 1.5 −18.6% Weekly 13 2.3 1.9 −16.2% Weekly 1–52 2.0 1.9 −5.0% Annual 1 3.4 1.9 −42.9% Forecas ng large collec ons of related me series Temporal hierarchies 46
except the last year Base forecasts using auto.arima(). Reconciled using WLSV. Mean Absolute Scaled Errors for 1, 4 and 13 weeks ahead using a rolling origin. Aggr. Level h Base Reconciled Change Weekly 1 1.6 1.3 −17.2% Weekly 4 1.9 1.5 −18.6% Weekly 13 2.3 1.9 −16.2% Weekly 1–52 2.0 1.9 −5.0% Annual 1 3.4 1.9 −42.9% Forecas ng large collec ons of related me series Temporal hierarchies 46
except the last year Base forecasts using auto.arima(). Reconciled using WLSV. Mean Absolute Scaled Errors for 1, 4 and 13 weeks ahead using a rolling origin. Aggr. Level h Base Reconciled Change Weekly 1 1.6 1.3 −17.2% Weekly 4 1.9 1.5 −18.6% Weekly 13 2.3 1.9 −16.2% Weekly 1–52 2.0 1.9 −5.0% Annual 1 3.4 1.9 −42.9% Forecas ng large collec ons of related me series Temporal hierarchies 46
except the last year Base forecasts using auto.arima(). Reconciled using WLSV. Mean Absolute Scaled Errors for 1, 4 and 13 weeks ahead using a rolling origin. Aggr. Level h Base Reconciled Change Weekly 1 1.6 1.3 −17.2% Weekly 4 1.9 1.5 −18.6% Weekly 13 2.3 1.9 −16.2% Weekly 1–52 2.0 1.9 −5.0% Annual 1 3.4 1.9 −42.9% Forecas ng large collec ons of related me series Temporal hierarchies 46
except the last year Base forecasts using auto.arima(). Reconciled using WLSV. Mean Absolute Scaled Errors for 1, 4 and 13 weeks ahead using a rolling origin. Aggr. Level h Base Reconciled Change Weekly 1 1.6 1.3 −17.2% Weekly 4 1.9 1.5 −18.6% Weekly 13 2.3 1.9 −16.2% Weekly 1–52 2.0 1.9 −5.0% Annual 1 3.4 1.9 −42.9% Forecas ng large collec ons of related me series Temporal hierarchies 46
except the last year Base forecasts using auto.arima(). Reconciled using WLSV. Mean Absolute Scaled Errors for 1, 4 and 13 weeks ahead using a rolling origin. Aggr. Level h Base Reconciled Change Weekly 1 1.6 1.3 −17.2% Weekly 4 1.9 1.5 −18.6% Weekly 13 2.3 1.9 −16.2% Weekly 1–52 2.0 1.9 −5.0% Annual 1 3.4 1.9 −42.9% Forecas ng large collec ons of related me series Temporal hierarchies 46
2000, IJF). In total 3003 series. 1,428 monthly series with a test sample of 12 observa ons each. 756 quarterly series with a test sample of 8 observa ons each. Forecast each series with ETS models. Forecas ng large collec ons of related me series Temporal hierarchies 47
2000, IJF). In total 3003 series. 1,428 monthly series with a test sample of 12 observa ons each. 756 quarterly series with a test sample of 8 observa ons each. Forecast each series with ETS models. Forecas ng large collec ons of related me series Temporal hierarchies 47
2000, IJF). In total 3003 series. 1,428 monthly series with a test sample of 12 observa ons each. 756 quarterly series with a test sample of 8 observa ons each. Forecast each series with ETS models. Forecas ng large collec ons of related me series Temporal hierarchies 47
2000, IJF). In total 3003 series. 1,428 monthly series with a test sample of 12 observa ons each. 756 quarterly series with a test sample of 8 observa ons each. Forecast each series with ETS models. Forecas ng large collec ons of related me series Temporal hierarchies 47
h BU WLSH WLSV WLSS Annual 1 −20.9 -22.7 −22.8 -22.7 Semi-annual 3 −4.5 −6.0 −6.2 -4.8 Quarterly 6 0.0 −0.2 −1.1 -0.3 Forecas ng large collec ons of related me series Temporal hierarchies 49
from CRAN install.packages("thief") Install from github library(devtools) install github("/robjhyndman/thief") Usage thief(y) Forecas ng large collec ons of related me series Temporal hierarchies 50
from CRAN install.packages("thief") Install from github library(devtools) install github("/robjhyndman/thief") Usage thief(y) Forecas ng large collec ons of related me series Temporal hierarchies 50
from CRAN install.packages("thief") Install from github library(devtools) install github("/robjhyndman/thief") Usage thief(y) Forecas ng large collec ons of related me series Temporal hierarchies 50
Linear Unbiased Forecasts 3 Applica on: Australian tourism 4 Fast computa on tricks 5 hts package for R 6 Temporal hierarchies 7 References Forecas ng large collec ons of related me series References 51
Han Lin Shang (2011). “Op mal combina on forecasts for hierarchical me series”. Computa onal Sta s cs & Data Analysis 55(9), 2579–2589. Rob J Hyndman, Alan J Lee, and Earo Wang (2016). “Fast computa on of reconciled forecasts for hierarchical and grouped me series”. Computa onal Sta s cs & Data Analysis 97, 16–32. Shanika L Wickramasuriya, George Athanasopoulos, and Rob J Hyndman (2015). Forecas ng hierarchical and grouped me series through trace minimiza on. Working paper 15/15. Monash University George Athanasopoulos, Rob J Hyndman, Nikolaos Kourentzes, and Fo os Petropoulos (2015). Forecas ng with temporal hierarchies. Working paper. Monash University Rob J Hyndman, Alan J Lee, Earo Wang, and Shanika Wickramasuriya (2016). hts: Hierarchical and Grouped Time Series. R package v5.0 on CRAN. Rob J Hyndman and Nikolaos Kourentzes (2016). thief: Temporal Hierarchical Forecas ng. R package v0.2 on CRAN. Forecas ng large collec ons of related me series References 52
Han Lin Shang (2011). “Op mal combina on forecasts for hierarchical me series”. Computa onal Sta s cs & Data Analysis 55(9), 2579–2589. Rob J Hyndman, Alan J Lee, and Earo Wang (2016). “Fast computa on of reconciled forecasts for hierarchical and grouped me series”. Computa onal Sta s cs & Data Analysis 97, 16–32. Shanika L Wickramasuriya, George Athanasopoulos, and Rob J Hyndman (2015). Forecas ng hierarchical and grouped me series through trace minimiza on. Working paper 15/15. Monash University George Athanasopoulos, Rob J Hyndman, Nikolaos Kourentzes, and Fo os Petropoulos (2015). Forecas ng with temporal hierarchies. Working paper. Monash University Rob J Hyndman, Alan J Lee, Earo Wang, and Shanika Wickramasuriya (2016). hts: Hierarchical and Grouped Time Series. R package v5.0 on CRAN. Rob J Hyndman and Nikolaos Kourentzes (2016). thief: Temporal Hierarchical Forecas ng. R package v0.2 on CRAN. Forecas ng large collec ons of related me series References 52 ¯ More informa on: robjhyndman.com