In what is now a roughly annual event, the forecast package has been updated on CRAN with a new version, this time 8.0. A few of the more important new features are described below. Check residuals…
In what is now a roughly annual event, the forecast package has been updated on CRAN with a new version, this time 8.0.
A few of the more important new features are described below.
A common task when building forecasting models is to check that the residuals satisfy some assumptions (that they are uncorrelated, normally distributed, etc.). The new function
makes this very easy: it produces a time plot, an ACF, a histogram with super-imposed normal curve, and does a Ljung-Box test on the residuals with appropriate number of lags and degrees of freedom.
<pre class="inline:true decode:1 " >##
## Ljung-Box test
## data: residuals
## Q* = 7.8338, df = 8, p-value = 0.4499
## Model df: 2. Total lags used: 10
This should work for all the modelling functions in the package, as well as some of the time series modelling functions in the
Different types of residuals
Usually, residuals are computed as the difference between observations and the corresponding one-step forecasts. But for some models, residuals are computed differently; for example, a multiplicative ETS model or a model with a Box-Cox transformation. So the
function now has an additional argument to deal with this situation.
“Innovation residuals”” correspond to the white noise process that drives the evolution of the time series model. “Response residuals” are the difference between the observations and the fitted values (as with GLMs). For homoscedastic models, the innovation residuals and the one-step response residuals are identical. “Regression residuals” are also available for regression models with ARIMA errors, and are equal to the original data minus the effect of the regression variables. If there are no regression variables, the errors will be identical to the original series (possibly adjusted to have zero mean).
Some new graphs
function in the
package is nice, but it does not have a good default bandwidth. So I added the
function which provides a quick histogram with good defaults. You can also overlay a normal density curve or a kernel density estimate.
function is useful for studying seasonal patterns and how they change over time. It now has a
argument to create graphs like this.
I often want to add a time series line to an existing plot. Base graphics has
which works well when a time series is passed as an argument. So I added
which is similar (but more general). It is an S3 method like
, and adds a layer to an existing
will eventually form part of the next release of
, but for now it is available in the
package. There are methods provided for
functions have been added. These were discussed in a previous post.
function has been added, which implements the procedure discussed in Bergmeir et al (2016) for bagging ETS forecasts.
head and tail of time series
I’ve long found it annoying that
do not work on multiple time series. So I added some functions to the package so they now work.
Imports and Dependencies
The pipe operator from the
package is now imported. So you don’t need to load the
package to use it.
There are now no packages that are loaded with
– everything required is imported. This makes the start up much cleaner (no more annoying messages from all those packages being loaded). Instead, some random tips are occasionally printed when you load the forecast package (much like
There is quite a bit more — see the Changelog for a list.