Package thief. R topics documented: January 24, Version 0.3 Title Temporal Hierarchical Forecasting

Similar documents
Package MAPA. R topics documented: January 5, Type Package Title Multiple Aggregation Prediction Algorithm Version 2.0.4

Package Tcomp. June 6, 2018

Package TSPred. April 5, 2017

Forecasting: principles and practice. Rob J Hyndman 4 Hierarchical forecasting

Optimal forecast reconciliation for big time series data

Using Temporal Hierarchies to Predict Tourism Demand

Package invgamma. May 7, 2017

Package gtheory. October 30, 2016

Package polypoly. R topics documented: May 27, 2017

Package ShrinkCovMat

Package tspi. August 7, 2017

Package jmcm. November 25, 2017

Package WaveletArima

Forecasting with R A practical workshop

Package TimeSeries.OBeu

Package scpdsi. November 18, 2018

Package reinforcedpred

Package FinCovRegularization

Package bigtime. November 9, 2017

Fast computation of reconciled forecasts in hierarchical and grouped time series

Package HIMA. November 8, 2017

Package varband. November 7, 2016

Package MultisiteMediation

Package OGI. December 20, 2017

Package SK. May 16, 2018

Package RTransferEntropy

Package hds. December 31, 2016

Package xdcclarge. R topics documented: July 12, Type Package

Package covsep. May 6, 2018

Package bivariate. December 10, 2018

Package clogitboost. R topics documented: December 21, 2015

Package BayesNI. February 19, 2015

Package asus. October 25, 2017

Package robustrao. August 14, 2017

Package NlinTS. September 10, 2018

Package cartogram. June 21, 2018

Package TSF. July 15, 2017

Package SimSCRPiecewise

Package Delaporte. August 13, 2017

Package effectfusion

Package rdefra. March 20, 2017

Package gk. R topics documented: February 4, Type Package Title g-and-k and g-and-h Distribution Functions Version 0.5.

Package BNN. February 2, 2018

Package face. January 19, 2018

Forecasting hierarchical (and grouped) time series

Package noncompliance

Package CEC. R topics documented: August 29, Title Cross-Entropy Clustering Version Date

Package SEMModComp. R topics documented: February 19, Type Package Title Model Comparisons for SEM Version 1.0 Date Author Roy Levy

Package ltsbase. R topics documented: February 20, 2015

Package Metrics. November 3, 2017

Package supernova. February 23, 2018

Package solrad. November 5, 2018

Package MicroMacroMultilevel

Package RSwissMaps. October 3, 2017

Package EMVS. April 24, 2018

Package NonpModelCheck

Package factorqr. R topics documented: February 19, 2015

Package SpatialVS. R topics documented: November 10, Title Spatial Variable Selection Version 1.1

Package RATest. November 30, Type Package Title Randomization Tests

Package AID. R topics documented: November 10, Type Package Title Box-Cox Power Transformation Version 2.3 Date Depends R (>= 2.15.

Package horseshoe. November 8, 2016

Package SpatPCA. R topics documented: February 20, Type Package

Package coop. November 14, 2017

Package nowcasting. April 25, Type Package

Package ARCensReg. September 11, 2016

Package sscor. January 28, 2016

Package LIStest. February 19, 2015

Package SpatialPack. March 20, 2018

Package chemcal. July 17, 2018

Package dominanceanalysis

Package EnergyOnlineCPM

Package testassay. November 29, 2016

Package stability. R topics documented: August 23, Type Package

Package mpmcorrelogram

Package SMFilter. December 12, 2018

Package platetools. R topics documented: June 25, Title Tools and Plots for Multi-Well Plates Version 0.1.1

Package gma. September 19, 2017

Package darts. February 19, 2015

Package goftest. R topics documented: April 3, Type Package

Package CPE. R topics documented: February 19, 2015

Package matrixnormal

Package esreg. August 22, 2017

Package r2glmm. August 5, 2017

Package msu. September 30, 2017

Package convospat. November 3, 2017

Package ForecastCombinations

Optimal forecast reconciliation for hierarchical and grouped time series through trace minimization

Package elhmc. R topics documented: July 4, Type Package

Package IndepTest. August 23, 2018

Package nmw. October 20, 2017

Package CorrMixed. R topics documented: August 4, Type Package

Cross-temporal coherent forecasts for Australian tourism

Package nardl. R topics documented: May 7, Type Package

Package multdm. May 18, 2018

Time series can often be naturally disaggregated

Package bhrcr. November 12, 2018

Package baystability

Package ADPF. September 13, 2017

Package leiv. R topics documented: February 20, Version Type Package

Package rarhsmm. March 20, 2018

Transcription:

Version 0.3 Title Temporal Hierarchical Forecasting Package thief January 24, 2018 Methods and tools for generating forecasts at different temporal frequencies using a hierarchical time series approach. Depends R (>= 3.0.2), forecast (>= 7.2) Imports hts, ggplot2 LazyData yes ByteCompile TRUE BugReports https://github.com/robjhyndman/thief/issues License GPL-3 URL http://pkg.robjhyndman.com/thief, https://github.com/robjhyndman/thief RoxygenNote 6.0.1.9000 NeedsCompilation no Author Rob Hyndman [aut, cre, cph], Nikolaos Kourentzes [aut, cph] Maintainer Rob Hyndman <Rob.Hyndman@monash.edu> Repository CRAN Date/Publication 2018-01-24 05:06:33 UTC R topics documented: AEdemand......................................... 2 plot.tsaggregates...................................... 3 reconcilethief........................................ 4 thief............................................. 5 tsaggregates......................................... 7 Index 8 1

2 AEdemand AEdemand Accident and Emergency demand in the UK Format Weekly demand of Accident & Emergency departments in the UK, from 7 November 2010 to 7 June 2015. AEdemand An object of class ts. library(ggplot2) autoplot(aedemand, xlab="year", ylab="demand ('000)") + ggtitle("accident & Emergency Demand in the UK") ## Not run: # Demonstration of the adjustment of all temporal aggregates # using Total Emergency Admissions total <- AEdemand[,12] totalagg <- tsaggregates(total) plot(totalagg, main="total Emergency Admissions") # Base forecasts base <- list() for(i in 1:5) base[[i]] <- forecast(auto.arima(totalagg[[i]])) base[[6]] <- forecast(auto.arima(totalagg[[6]]), h=2) # Reconciled forecasts reconciled <- reconcilethief(base) main <- paste(names(totalagg)," (k=", 52/unlist(lapply(reconciled,frequency)),")",sep="") par(mfrow=c(2,3)) for(i in 6:1) { ylim <- range(base[[i]]$mean, base[[i]]$x, reconciled[[i]]$mean) plot(base[[i]], main=main[i], fcol='white', plot.conf=false, ylim=ylim, xlim=c(2010.5,2017.5)) polygon(c(2015.45, 2020, 2020, 2015.45), c(0, 0, 1e5, 1e5), col='grey', border=false)

plot.tsaggregates 3 lines(base[[i]]$mean, col='red', lty=2) lines(reconciled[[i]]$mean, col='blue') } ## End(Not run) plot.tsaggregates Plot time series aggregates Plots all temporal aggregations of a time series ## S3 method for class 'tsaggregates' plot(x, series = "all",...) ## S3 method for class 'tsaggregates' autoplot(object, series = "all",...) Arguments x tsaggregates object, produced by tsaggregates. series The indexes of the series to plot. By default, all series are plotted.... Other arguments passed to plot.ts or autoplot.ts. object tsaggregates object, produced by tsaggregates. Author(s) Rob J Hyndman deathagg <- tsaggregates(usaccdeaths) plot(deathagg, series=c(1,2,4,6)) library(ggplot2) autoplot(deathagg)

4 reconcilethief reconcilethief Reconcile temporal hierarchical forecasts Takes forecasts of time series at all levels of temporal aggregation and combines them using the temporal hierarchical approach of Athanasopoulos et al (2016). reconcilethief(forecasts, comb = c("struc", "mse", "ols", "bu", "shr", "sam"), mse = NULL, residuals = NULL, returnall = TRUE, aggregatelist = NULL) Arguments forecasts comb mse residuals returnall aggregatelist List of forecasts. Each element must be a time series of forecasts, or a forecast object. The number of forecasts should be equal to k times the seasonal period for each series, where k is the same across all series. Combination method of temporal hierarchies, taking one of the following values: "struc" Structural scaling - weights from temporal hierarchy "mse" Variance scaling - weights from in-sample MSE "ols" Unscaled OLS combination weights "bu" Bottom-up combination i.e., all aggregate forecasts are ignored. "shr" GLS using a shrinkage (to block diagonal) estimate of residuals "sam" GLS using sample covariance matrix of residuals A vector of one-step MSE values corresponding to each of the forecast series. List of residuals corresponding to each of the forecast models. Each element must be a time series of residuals. If forecast contains a list of forecast objects, then the residuals will be extracted automatically and this argument is not needed. However, it will be used if not NULL. If TRUE, a list of time series corresponding to the first argument is returned, but now reconciled. Otherwise, only the most disaggregated series is returned. (optional) User-selected list of forecast aggregates to consider Value List of reconciled forecasts in the same format as forecast. If returnall==false, only the most disaggregated series is returned. Author(s) Rob J Hyndman

thief 5 See Also thief, tsaggregates # Construct aggregates aggts <- tsaggregates(usaccdeaths) # Compute forecasts fc <- list() for(i in seq_along(aggts)) fc[[i]] <- forecast(auto.arima(aggts[[i]]), h=2*frequency(aggts[[i]])) # Reconcile forecasts reconciled <- reconcilethief(fc) # Plot forecasts before and after reconcilation par(mfrow=c(2,3)) for(i in seq_along(fc)) { plot(reconciled[[i]], main=names(aggts)[i]) lines(fc[[i]]$mean, col='red') } thief Temporal hierarchical forecasting Takes a time series as input and produces forecasts using the temporal hierarchical approach of Athanasopoulos et al (2016). thief(y, m = frequency(y), h = m * 2, comb = c("struc", "mse", "ols", "bu", "shr", "sam"), usemodel = c("ets", "arima", "theta", "naive", "snaive"), forecastfunction = NULL, aggregatelist = NULL,...) Arguments y m h comb Time series input Seasonal period Forecast horizon Combination method of temporal hierarchies, taking one of the following values: "struc" Structural scaling - weights from temporal hierarchy

6 thief Details Value usemodel "mse" Variance scaling - weights from in-sample MSE "ols" Unscaled OLS combination weights "bu" Bottom-up combination i.e., all aggregate forecasts are ignored. "shr" GLS using a shrinkage (to block diagonal) estimate of residuals "sam" GLS using sample covariance matrix of residuals Model used for forecasting each aggregation level: "ets" exponential smoothing, using the ets function. "arima" arima, using the auto.arima function. "theta" theta method, using the thetaf function. "naive" random walk forecasts "snaive" seasonal naive forecasts, based on the last year of observed data. forecastfunction User-defined function to be used instead of usemodel. The function must take a time series as the first argument, and the forecast horizon as the second argument. It must return an object of class forecast. aggregatelist User-selected list of forecast aggregates to consider... Arguments to be passed to the time series modelling function (such as ets or auto.arima), or to forecastfunction. This function computes the temporal aggregates of y using tsaggregates, then calculates all forecasts using the model function specified by usemodel or forecastfunction, and finally reconciles the forecasts using reconcilethief. The reconciled forecasts of y are returned. forecast object. Author(s) See Also Rob J Hyndman and Nikolaos Kourentzes reconcilethief ## Not run: # Select ARIMA models for all series using auto.arima() z <- thief(aedemand[,12], usemodel='arima') plot(z) # Use your own function ftbats <- function(y,h,...){forecast(tbats(y),h,...)} z <- thief(aedemand[,12], forecastfunction=ftbats)

tsaggregates 7 plot(z) ## End(Not run) tsaggregates Non-overlapping temporal aggregation of a time series Produces all temporal aggregations for frequencies greater than 1 tsaggregates(y, m = frequency(y), align = c("end", "start"), aggregatelist = NULL) Arguments y m align aggregatelist Univariate time series of class ts. Integer seasonal period Indicates how the aggregates are to be aligned: either with the start of the series or the end of the series. For forecasting purposes, it should be set to end. User-selected list of aggregates to consider. Value A list of time series. The first element is the series y, followed by series with increasing levels of aggregation. The last element is the "annual" series (i.e., the series aggregated over all seasons). Author(s) See Also Rob J Hyndman plot.tsaggregates tsaggregates(usaccdeaths)

Index Topic datasets AEdemand, 2 AEdemand, 2 auto.arima, 6 autoplot.ts, 3 autoplot.tsaggregates (plot.tsaggregates), 3 ets, 6 plot.ts, 3 plot.tsaggregates, 3, 7 reconcilethief, 4, 6 thetaf, 6 thief, 5, 5 tsaggregates, 3, 5, 6, 7 8