# Hierarchical forecasting with hts v4.0

**Hyndsight » R**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

A new version of my `hts`

package for R is now on CRAN. It was completely re-written from scratch. Not a single line of code survived. There are some minor syntax changes, but the biggest change is speed and scope. This version is many times faster than the previous version and can handle hundreds of thousands of time series without complaining.

The speed-up is due to some new research I am doing with Alan Lee (University of Auckland). Usually, we would write the paper first, and then release a package implementing the ideas. But this time, the package was produced first and the papers will follow in the next few weeks.

For those unfamiliar with the techniques and concepts involved with hierarchical forecasting, there is an introduction in Section 9.4 of my forecasting textbook. The basic idea is that you need to forecast a large number of time series under the constraint that the forecasts of some series have to add up to equal the forecasts of other series. For example, the forecasts of sales in each state need to equal to the forecasts of sales across the country. Our approach is to forecast all series independently, ignoring the constraints. Then adjust all the forecasts so the constraints are satisfied. We have a neat result that gives the optimal (least squares) reconciliation.

Users of previous versions of the package should read the vignette (pp.10–11) which explains some syntax and function changes.

Regular readers of this blog will have noticed a couple of references to my new research assistant, Earo Wang. She has been working with me on R package development over the Australian summer. The new version of the hts package was one of the main projects she has worked on, and the many improvements are largely due to her considerable talents!

**leave a comment**for the author, please follow the link and comment on their blog:

**Hyndsight » R**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.