Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
The forecasting PackageJuly 28, 2007
Contains forecast fma Mcomp
Version 1.07
Date 2007-07-25
Depends R (>= 2.0.0), graphics, stats, tseries
LazyData yes
LazyLoad yes
Author Rob J Hyndman <[email protected]>
Maintainer Rob J Hyndman <[email protected]>
License GPL (version 2 or later).
URL http://www.robhyndman.info/Rlibrary/forecast/
Contents
Package ‘forecast’ 1BoxCox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1arima . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2arima.errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4best.arima . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5croston . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6ets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8fitted.Arima . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10forecast.Arima . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10forecast.HoltWinters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12forecast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13forecast.StructTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14forecasterrors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16forecast.ets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17plot.forecast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18gas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19gof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20gold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21meanf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21monthdays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23na.interp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23ndiffs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24plot.ets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25rwf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26seasadj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27seasonaldummy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28seasonplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29ses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30simulate.ets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31sindexf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32splinef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33thetaf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35tsdisplay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36wineind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37woolyrnq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
i
ii CONTENTS
Package ‘fma’ 39advert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39advsales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40airpass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40auto . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41bank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42beer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42bicoal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43books . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43boston . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44bricksq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45canadian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45capital . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46cement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46chicken . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47condmilk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48copper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48copper1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49copper2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49copper3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50cowtemp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50cpimel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51dexter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51dj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52dole . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53dowjones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53econsumption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54eggs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54eknives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55elco . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55elec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56expenditure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56fancy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57french . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57housing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58hsales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59hsales2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59huron . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60ibm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60ibmclose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62internet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62invent15 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63jcars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63kkong . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64labour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65lynx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65milk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
CONTENTS iii
mink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67mortal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67motel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68motion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68nail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69oilprice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70olympic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70ozone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71paris . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71pcv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72petrol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73pigs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73plastics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74pollution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74productC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75pulpprice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76qelec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76qsales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77running . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77sales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78schizo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78shampoo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79sheep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80ship . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80shipex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81strikes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81telephone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82texasgas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82ukdeaths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83usdeaths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84uselec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84ustreas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85wagesuk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85wheat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86wn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86wnoise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87writing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Package ‘Mcomp’ 89M1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89plot.Mdata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90subset.Mcomp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Index 93
iv CONTENTS
Package ‘forecast’
Title Forecasting functions for time series
Description Various functions to aid in univariate time series forecasting including exponentialsmoothing via state space models, arima models, and many more.
BoxCox Box Cox Transformation
Description
BoxCox() returns a transformation of the input variable using a Box-Cox transformation. InvBox-Cox() reverses the transformation.
Usage
BoxCox(x,lambda)InvBoxCox(x,lambda)
Arguments
x a numeric vector or time series
lambda transformation parameter
Details
The Box-Cox transformation is given by
fλ(x) =xλ − 1
λ
if λ 6= 0. For λ = 0,f0(x) = log(x)
.
Value
a numeric vector of the same length as x.
1
2 arima
Author(s)
Rob J Hyndman
References
Box, G. E. P. and Cox, D. R. (1964) An analysis of transformations. JRSS B 26 211–246.
Examples
lynx.sqrt <- BoxCox(lynx,0.5)lynx.fit <- ar(lynx.sqrt)plot(forecast(lynx.fit,h=20),lambda=0.5)
arima Fit ARIMA model to univariate time series
Description
Largely a wrapper for the arima function in the stats package. The main difference is that thisfunction returns some additional information that is required by the forecast.Arima function.Also, it is possible to take an ARIMA model from a previous call to arima and re-apply it to thedata x.
Usage
arima(x, order = c(0, 0, 0), seasonal = list(order = c(0, 0, 0), period = NA),xreg = NULL, include.mean = TRUE, include.drift = FALSE,transform.pars = TRUE, fixed = NULL, init = NULL,method = c("CSS-ML", "ML", "CSS"), n.cond,optim.control = list(), kappa = 1e6, model=NULL)
Arguments
x a univariate time series
order A specification of the non-seasonal part of the ARIMA model: the three com-ponents (p, d, q) are the AR order, the degree of differencing, and the MA order.
seasonal A specification of the seasonal part of the ARIMA model, plus the period (whichdefaults to frequency(x)). This should be a list with components order and pe-riod, but a specification of just a numeric vector of length 3 will be turned into asuitable list with the specification as the order.
xreg Optionally, a vector or matrix of external regressors, which must have the samenumber of rows as x.
include.mean Should the ARIMA model include a mean term? The default is TRUE for un-differenced series, FALSE for differenced ones (where a mean would not affectthe fit nor predictions).
arima 3
include.driftShould the ARIMA model include a linear drift term? (i.e., a linear regressionwith ARIMA errors is fitted.) The default is FALSE.
transform.parsLogical. If true, the AR parameters are transformed to ensure that they remainin the region of stationarity. Not used for method = "CSS".
fixed optional numeric vector of the same length as the total number of parameters.If supplied, only NA entries in fixed will be varied. transform.pars = TRUEwill be overridden (with a warning) if any AR parameters are fixed. It may bewise to set transform.pars = FALSE when fixing MA parameters, especially nearnon-invertibility.
init optional numeric vector of initial parameter values. Missing values will be filledin, by zeroes except for regression coefficients. Values already specified in fixedwill be ignored.
method Fitting method: maximum likelihood or minimize conditional sum-of-squares.The default (unless there are missing values) is to use conditional-sum-of-squaresto find starting values, then maximum likelihood.
n.cond Only used if fitting by conditional-sum-of-squares: the number of initial obser-vations to ignore. It will be ignored if less than the maximum lag of an ARterm.
optim.controlList of control parameters for optim.
kappa the prior variance (as a multiple of the innovations variance) for the past obser-vations in a differenced model. Do not reduce this.
model Output from a previous call to arima. If model is passed, this same model isfitted to x without re-estimating any parameters.
Details
See the arima function in the stats package.
Value
See the arima function in the stats package. The additional objects returned are
x The time series data
xreg The regressors used in fitting (when relevant).
Author(s)
Rob J Hyndman
See Also
arima
4 arima.errors
Examples
fit <- arima(WWWusage,order=c(3,1,0))plot(forecast(fit,h=20))
air.model <- arima(AirPassengers[1:100],c(0,1,1))air.model2 <- arima(AirPassengers,model=air.model)outofsample <- ts(fitted(air.model2)[-c(1:100)],s=1957+4/12,f=12)
arima.errors ARIMA errors
Description
Returns original time series after adjusting for regression variables. These are not the same as theresiduals. If there are no regression variables in the ARIMA model, then the errors will be identicalto the original series. If there are regression variables in the ARIMA model, then the errors willbe equal to the original series minus the effect of the regression variables, but leaving in the serialcorrelation that is modelled with the AR and MA terms. If you want the "residuals", then useresiduals(z)..
Usage
arima.errors(z)
Arguments
z Fitted ARIMA model from arima
Value
A time series containing the "errors".
Author(s)
Rob J Hyndman
See Also
arima, residuals
Examples
ukdeaths.fit <- arima(UKDriverDeaths,c(1,0,1),c(0,1,1),xreg=Seatbelts[,"law"])ukdeaths.errors <- arima.errors(ukdeaths.fit)par(mfrow=c(2,1))plot(UKDriverDeaths)plot(ukdeaths.errors)
best.arima 5
best.arima Fit best ARIMA model to univariate time series
Description
Returns best ARIMA model according to either AIC, AICc or BIC value. The function conducts asearch over possible model within the order constraints provided.
Usage
auto.arima(x, d = NA, D = NA, max.p = 5, max.q = 5,max.P = 2, max.Q = 2, max.order = 5,start.p=2, start.q=2, start.P=1, start.Q=1,
stationary = FALSE, ic = c("aic","aicc", "bic"),stepwise=TRUE, trace=FALSE)
Arguments
x a univariate time series
d Order of first-differencing. If missing, will choose a value based on KPSS test.
D Order of seasonal-differencing. If missing, will choose a value based on CHtest.
max.p Maximum value of p
max.q Maximum value of q
max.P Maximum value of P
max.Q Maximum value of Q
max.order Maximum value of p+q+P+Q if model selection is not stepwise.
start.p Starting value of p in stepwise procedure.
start.q Starting value of q in stepwise procedure.
start.P Starting value of P in stepwise procedure.
start.Q Starting value of Q in stepwise procedure.
stationary If TRUE, restricts search to stationary models.
ic Information criterion to be used in model selection.
stepwise If TRUE, will do stepwise selection (faster). Otherwise, it searches over all mod-els. Non-stepwise selection can be very slow, especially for seasonal models.
trace If TRUE, the list of ARIMA models considered will be reported.
Details
Non-stepwise selection can be slow, especially for seasonal data. Non-seasonal differences chosenusing kpss.test. Seasonal differences chosen using a variation on the Canova-Hansen test.Stepwise algorithm outlined in Hyndman and Khandakar (2007).
6 croston
Value
Same as for arima
Author(s)
Rob J Hyndman
References
Hyndman, R.J. and Khandakar, Y. (2007) "Automatic time series forecasting: The forecast packagefor R", Journal of Statistical Software, to appear.
See Also
arima
Examples
fit <- auto.arima(WWWusage)plot(forecast(fit,h=20))
croston Forecasts for intermittent demand using Croston’s method
Description
Returns forecasts and other information for Croston’s forecasts applied to x.
Usage
croston(x, h=10, alpha=0.1)
Arguments
x a numeric vector or time series
h Number of periods for forecasting.
alpha Value of alpha. Default value is 0.1.
Details
Based on Croston’s (1972) method for intermittent demand forecasting, also described in Shenstoneand Hyndman (2005). Croston’s method involves using simple exponential smoothing (SES) on thenon-zero elements of the time series and a separate application of SES to the times between non-zero elements of the time series. The smoothing parameters of the two applications of SES areassumed to be equal and are denoted by alpha.
Note that prediction intervals are not computed as Croston’s method has no underlying stochasticmodel.
croston 7
Value
An object of class "forecast" is a list containing at least the following elements:
model A list containing information about the fitted model
method The name of the forecasting method as a character string
mean Point forecasts as a time series
x The original time series (either object itself or the time series used to createthe model stored as object).
residuals Residuals from the fitted model. That is x minus fitted values.
fitted Fitted values (one-step forecasts)
The function summary is used to obtain and print a summary of the results, while the functionplot produces a plot of the forecasts.
The generic accessor functions fitted.values and residuals extract useful features of thevalue returned by croston and associated functions.
Author(s)
Rob J Hyndman
References
Croston, J. (1972) "Forecasting and stock control for intermittent demands", Operational ResearchQuarterly, 23(3), 289-303.
Shenstone, L., and Hyndman, R.J. (2005) "Stochastic models underlying Croston’s method forintermittent demand forecasting". Journal of Forecasting, 24, 389-402.
See Also
ses.
Examples
x <- rpois(20,lambda=.3)fcast <- croston(x)plot(fcast)
8 ets
ets Exponential smoothing state space model
Description
Returns ets model applied to x.
Usage
ets(y, model="ZZZ", damped=NULL, alpha=NULL, beta=NULL, gamma=NULL, phi=NULL,additive.only=FALSE, lower=c(rep(0.01,3), 0.8), upper=c(rep(0.99,3),0.98),opt.crit=c("lik","amse","mse","sigma"), nmse=3,bounds=c("both","usual","admissible"), ic=c("aic","aicc","bic"))
Arguments
y a numeric vector or time series
model Usually a three-character string identifying method using the framework termi-nology of Hyndman et al. (2002) and Hyndman et al. (2008). The first letterdenotes the error type ("A", "M" or "Z"); the second letter denotes the trend type("N","A","M" or "Z"); and the third letter denotes the season type ("N","A","M"or "Z"). In all cases, "N"=none, "A"=additive, "M"=multiplicative and "Z"=automaticallyselected. So, for example, "ANN" is simple exponential smoothing with addi-tive errors, "MAM" is multiplicative Holt-Winters’ method with multiplicativeerrors, and so on. It is also possible for the model to be equal to the outputfrom a previous call to ets. In this case, the same model is fitted to y withoutre-estimating any parameters.
damped If TRUE, use a damped trend (either additive or multiplicative). If NULL, bothdamped and non-damped trends will be tried and the best model (according tothe information criterion ic) returned.
alpha Value of alpha. If NULL, it is estimated.
beta Value of beta. If NULL, it is estimated.
gamma Value of gamma. If NULL, it is estimated.
phi Value of phi. If NULL, it is estimated.additive.only
If TRUE, will only consider additive models. Default is FALSE.
lower Lower bounds for the parameters (alpha, beta, gamma, phi)
upper Upper bounds for the parameters (alpha, beta, gamma, phi)
opt.crit Optimization criterion. One of "mse" (Mean Square Error), "amse" (AverageMSE over first nmse forecast horizons), "sigma" (Standard deviation of residu-als), or "lik" (Log-likelihood, the default).
nmse Number of steps for average multistep MSE (1<=nmse<=10).
ets 9
bounds Type of parameter space to impose: "usual" indicates all parameters mustlie between specified lower and upper bounds; "admissible" indicates pa-rameters must lie in the admissible space; "both" (default) takes the intersec-tion of these regions.
ic Information criterion to be used in model selection.
Details
Based on the classification of methods as described in Hyndman et al (2008).
The methodology is fully automatic. The only required argument for ets is the time series. Themodel is chosen automatically if not specified. This methodology performed extremely well on theM3-competition data. (See Hyndman, et al, 2002, below.)
Value
An object of class "ets".
The generic accessor functions fitted.values and residuals extract useful features of thevalue returned by ets and associated functions.
Author(s)
Rob J Hyndman
References
Hyndman, R.J., Koehler, A.B., Snyder, R.D., and Grose, S. (2002) "A state space framework forautomatic forecasting using exponential smoothing methods", International J. Forecasting, 18(3),439–454.
Hyndman, R.J., Akram, Md., and Archibald, B. (2007) "The admissible parameter space for expo-nential smoothing models". Annals of Statistical Mathematics, to appear.
Hyndman, R.J., Koehler, A.B., Ord, J.K., and Snyder, R.D. (2008) Forecasting with exponentialsmoothing: the state space approach, Springer-Verlag. http://www.robhyndman.info/expsmooth.
See Also
HoltWinters, rwf, arima.
Examples
fit <- ets(USAccDeaths)plot(forecast(fit))
10 forecast.Arima
fitted.Arima One-step in-sample forecasts using ARIMA models
Description
Returns one-step forecasts for the data used in fitting the ARIMA model.
Usage
fitted.Arima(object,...)
Arguments
object An object of class "Arima". Usually the result of a call to arima.... Other arguments.
Value
An time series of the one-step forecasts.
Author(s)
Rob J Hyndman
See Also
forecast.Arima.
Examples
fit <- arima(WWWusage,c(3,1,0))plot(WWWusage)lines(fitted(fit),col=2)
forecast.Arima Forecasting using ARIMA models
Description
Returns forecasts and other information for univariate ARIMA models.
Usage
## S3 method for class 'Arima':forecast(object, h=ifelse(object$arma[5]>1,2*object$arma[5],10),
conf=c(80,95), fan=FALSE, xreg=NULL,...)## S3 method for class 'ar':forecast(object, h=10, conf=c(80,95), fan=FALSE, ...)
forecast.Arima 11
Arguments
object An object of class "Arima" or "ar". Usually the result of a call to arima orar.
h Number of periods for forecastingconf Confidence level for prediction intervals.fan If TRUE, conf is set to seq(50,99,by=1). This is suitable for fan plots.xreg Future values of an regression variables (for class Arima objects only).... Other arguments.
Details
This function calls predict.arima or predict.ar and constructs an object of class "forecast"from the results.
Value
An object of class "forecast".
The function summary is used to obtain and print a summary of the results, while the functionplot produces a plot of the forecasts and prediction intervals.
The generic accessor functions fitted.values and residuals extract useful features of thevalue returned by forecast.Arima.
An object of class "forecast" is a list containing at least the following elements:
model A list containing information about the fitted modelmethod The name of the forecasting method as a character stringmean Point forecasts as a time serieslower Lower limits for prediction intervalsupper Upper limits for prediction intervalsconf The confidence values associated with the prediction intervalsx The original time series (either object itself or the time series used to create
the model stored as object).residuals Residuals from the fitted model. That is x minus fitted values.fitted Fitted values (one-step forecasts)
Author(s)
Rob J Hyndman
See Also
predict.arima, predict.ar, rwf, arima.
Examples
fit <- arima(WWWusage,c(3,1,0))plot(forecast(fit))
12 forecast.HoltWinters
forecast.HoltWintersForecasting using Holt-Winters objects
Description
Returns forecasts and other information for univariate Holt-Winters time series models.
Usage
## S3 method for class 'HoltWinters':forecast(object, h=ifelse(frequency(object$x)>1,2*frequency(object$x),10),
conf=c(80,95),fan=FALSE,...)
Arguments
object An object of class "HoltWinters". Usually the result of a call to HoltWinters.
h Number of periods for forecasting
conf Confidence level for prediction intervals.
fan If TRUE, conf is set to seq(50,99,by=1). This is suitable for fan plots.
... Other arguments.
Details
This function calls predict.HoltWinters and constructs an object of class "forecast"from the results.
It is included for completeness, but the ets is recommended for use instead of HoltWinters.
Value
An object of class "forecast".
The function summary is used to obtain and print a summary of the results, while the functionplot produces a plot of the forecasts and prediction intervals.
The generic accessor functions fitted.values and residuals extract useful features of thevalue returned by forecast.HoltWinters.
An object of class "forecast" is a list containing at least the following elements:
model A list containing information about the fitted model
method The name of the forecasting method as a character string
mean Point forecasts as a time series
lower Lower limits for prediction intervals
upper Upper limits for prediction intervals
conf The confidence values associated with the prediction intervals
forecast 13
x The original time series (either object itself or the time series used to createthe model stored as object).
residuals Residuals from the fitted model. That is x minus fitted values.
fitted Fitted values (one-step forecasts)
Author(s)
Rob J Hyndman
See Also
predict.HoltWinters, HoltWinters.
Examples
fit <- HoltWinters(WWWusage,gamma=0)plot(forecast(fit))
forecast Forecasting time series
Description
forecast is a generic function for forecasting from time series or time series models. The func-tion invokes particular methods which depend on the class of the first argument.
For example, the function forecast.Arima makes forecasts based on the results produced byarima.
The function forecast.ts makes forecasts using exponential smoothing state space models.
Usage
forecast(...)## S3 method for class 'ts':forecast(x, h, conf=c(80,95), fan=FALSE, ...)
Arguments
x a time series or time series model for which forecasts are required
h Number of periods for forecasting
conf Confidence level for prediction intervals.
fan If TRUE, conf is set to seq(50,99,by=1). This is suitable for fan plots.
... Additional arguments affecting the forecasts produced. forecast.ts passesthese to forecast.ets
14 forecast.StructTS
Details
The default behaviour is to use a model estimated using ets.
Value
An object of class "forecast".
The function summary is used to obtain and print a summary of the results, while the functionplot produces a plot of the forecasts and prediction intervals.
The generic accessor functions fitted.values and residuals extract various useful featuresof the value returned by forecast$model.
An object of class "forecast" is a list containing at least the following elements:
model A list containing information about the fitted model
method The name of the forecasting method as a character string
mean Point forecasts as a time series
lower Lower limits for prediction intervals
upper Upper limits for prediction intervals
conf The confidence values associated with the prediction intervals
x The original time series (either object itself or the time series used to createthe model stored as object).
residuals Residuals from the fitted model. That is x minus fitted values.
fitted Fitted values (one-step forecasts)
Author(s)
Rob J Hyndman
See Also
Other functions which return objects of class "forecast" are forecast.ets, forecast.Arima,forecast.HoltWinters, forecast.StructTS, meanf, rwf, splinef, thetaf, croston,ses, holt, hw.
forecast.StructTS Forecasting using Structural Time Series models
Description
Returns forecasts and other information for univariate structural time series models.
Usage
## S3 method for class 'StructTS':forecast(object, h=ifelse(object$call$type=="BSM",2*object$xtsp[3],10),
conf=c(80,95), fan=FALSE, ...)
forecast.StructTS 15
Arguments
object An object of class "StructTS". Usually the result of a call to StructTS.
h Number of periods for forecasting
conf Confidence level for prediction intervals.
fan If TRUE, conf is set to seq(50,99,by=1). This is suitable for fan plots.
... Other arguments.
Details
This function calls predict.StructTS and constructs an object of class "forecast" fromthe results.
Value
An object of class "forecast".
The function summary is used to obtain and print a summary of the results, while the functionplot produces a plot of the forecasts and prediction intervals.
The generic accessor functions fitted.values and residuals extract useful features of thevalue returned by forecast.StructTS.
An object of class "forecast" is a list containing at least the following elements:
model A list containing information about the fitted model
method The name of the forecasting method as a character string
mean Point forecasts as a time series
lower Lower limits for prediction intervals
upper Upper limits for prediction intervals
conf The confidence values associated with the prediction intervals
x The original time series (either object itself or the time series used to createthe model stored as object).
residuals Residuals from the fitted model. That is x minus fitted values.
fitted Fitted values (one-step forecasts)
Author(s)
Rob J Hyndman
See Also
predict.StructTS, StructTS.
Examples
fit <- StructTS(WWWusage,"level")plot(forecast(fit))
16 forecasterrors
forecasterrors Forecast errors
Description
Returns range of summary measures of the error x-f. These are (usually) out-of-sample forecasterrors. Compare gof which provides a summary of in-sample forecast errors. All measures aredefined and discussed in Hyndman and Koehler (2006).
Usage
forecasterrors(f, x, test=1:length(x))
Arguments
f Vector of univariate forecasts or object of class code"forecast".
x Vector of actual values of the same length as f.
test Indicator of which elements of x and f to test.
Value
Vector giving forecast error measures.
Author(s)
Rob J Hyndman
References
Hyndman, R.J. and Koehler, A.B. (2006) "Another look at measures of forecast accuracy". Inter-national Journal of Forecasting, 22(4).
See Also
gof
Examples
fit1 <- rwf(EuStockMarkets[1:200,1],h=100)fit2 <- meanf(EuStockMarkets[1:200,1],h=100)forecasterrors(fit1,EuStockMarkets[201:300,1])forecasterrors(fit2,EuStockMarkets[201:300,1])plot(fit1)lines(EuStockMarkets[1:300,1])
forecast.ets 17
forecast.ets Forecasting using ETS models
Description
Returns forecasts and other information for univariate ETS models.
Usage
## S3 method for class 'ets':forecast(obj, h=ifelse(obj$m>1, 2*obj$m, 10), conf=c(80,95),
fan=FALSE, simulate=FALSE, bootstrap=FALSE, npaths=5000,...)
Arguments
obj An object of class "ets". Usually the result of a call to ets.h Number of periods for forecastingconf Confidence level for prediction intervals.fan If TRUE, conf is set to seq(50,99,by=1). This is suitable for fan plots.simulate If TRUE, prediction intervals produced by simulation rather than using analytic
formulae.bootstrap If TRUE, simulation uses resampled errors rather than normally distributed er-
rors.npaths Number of sample paths used in computing simulated prediction intervals.... Other arguments.
Value
An object of class "forecast".
The function summary is used to obtain and print a summary of the results, while the functionplot produces a plot of the forecasts and prediction intervals.
The generic accessor functions fitted.values and residuals extract useful features of thevalue returned by forecast.ets.
An object of class "forecast" is a list containing at least the following elements:
model A list containing information about the fitted modelmethod The name of the forecasting method as a character stringmean Point forecasts as a time serieslower Lower limits for prediction intervalsupper Upper limits for prediction intervalsconf The confidence values associated with the prediction intervalsx The original time series (either object itself or the time series used to create
the model stored as object).residuals Residuals from the fitted model. That is x minus fitted values.fitted Fitted values (one-step forecasts)
18 plot.forecast
Author(s)
Rob J Hyndman
See Also
ets, ses, holt, hw.
Examples
fit <- ets(USAccDeaths)plot(forecast(fit,h=48))
plot.forecast Forecast plot
Description
Plots a time series with forecasts and prediction intervals.
Usage
## S3 method for class 'forecast':plot(x, include, plot.conf = TRUE, shaded = TRUE, shadecols
= switch(1 + (length(x$conf) > 1), 7, length(x$conf):1),shadepalette=heat.colors(length(x$conf)+1)[-1], lambda = NULL,
col = 1, fcol = 4, ylim = NULL, main = NULL, ylab = "", xlab = "", ...)## S3 method for class 'splineforecast':plot(x,fitcol=2,...)
Arguments
x Forecast object produced by forecast.
include number of values from time series to include in plot
plot.conf Logical flag indicating whether to plot prediction intervals.
shaded Logical flag indicating whether prediction intervals should be shaded (TRUE)or lines (FALSE)
shadecols Colors for shaded prediction intervals
shadepalette Palette for shaded prediction intervals
lambda Box-Cox parameter. If present, function backtransforms data and forecasts us-ing InvBoxCox.
col the colour for the data line.
fcol the colour for the forecast line.
ylim Limits on y-axis
main Main title
gas 19
ylab Y-axis label
xlab X-axis label
fitcol Line colour for fitted values.
... additional arguments to plot.
Value
None.
Author(s)
Rob J Hyndman
References
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, Wiley:New York.
See Also
plot.ts
Examples
deaths.fit <- hw(USAccDeaths,h=48)plot(deaths.fit)
gas Australian monthly gas production
Description
Australian monthly gas production: 1956–1995.
Usage
gas
Format
Time series data
Source
Australian Bureau of Statistics.
20 gof
Examples
plot(gas)seasonplot(gas)tsdisplay(gas)
gof Goodness-of-fit for forecast model
Description
Returns range of summary measures of the in-sample errors. Compare forecasterrors whichprovides a summary of out-of-sample forecast errors. All measures are defined and discussed inHyndman and Koehler (2006).
Usage
gof(object)
Arguments
object An object of class "forecast"
Value
Vector giving in-sample error measures.
Author(s)
Rob J Hyndman
References
Hyndman, R.J. and Koehler, A.B. (2006) "Another look at measures of forecast accuracy". Inter-national Journal of Forecasting, 22(4).
Examples
fit1 <- rwf(Nile)fit2 <- meanf(Nile)gof(fit1)gof(fit2)
gold 21
gold Daily morning gold prices
Description
Daily morning gold prices in US dollars. 1 January 1985 – 31 March 1989.
Usage
data(gold)
Format
Time series data
Source
Time Series Data Library. http://www-personal.buseco.monash.edu.au/~hyndman/TSDL/
Examples
tsdisplay(gold)
meanf Mean Forecast
Description
Returns forecasts and prediction intervals for an iid model applied to x.
Usage
meanf(x, h=10, conf=c(80,95), fan=FALSE)
Arguments
x a numeric vector or time series
h Number of periods for forecasting
conf Confidence levels for prediction intervals.
fan If TRUE, conf is set to seq(50,99,by=1). This is suitable for fan plots.
22 meanf
Details
The iid model isYt = µ + Zt
where Zt is a normal iid error. Forecasts are given by
Yn(h) = µ
where µ is estimated by the sample mean.
Value
An object of class "forecast".
The function summary is used to obtain and print a summary of the results, while the functionplot produces a plot of the forecasts and prediction intervals.
The generic accessor functions fitted.values and residuals extract useful features of thevalue returned by meanf.
An object of class "forecast" is a list containing at least the following elements:
model A list containing information about the fitted model
method The name of the forecasting method as a character string
mean Point forecasts as a time series
lower Lower limits for prediction intervals
upper Upper limits for prediction intervals
conf The confidence values associated with the prediction intervals
x The original time series (either object itself or the time series used to createthe model stored as object).
residuals Residuals from the fitted model. That is x minus fitted values.
fitted Fitted values (one-step forecasts)
Author(s)
Rob J Hyndman
See Also
rwf
Examples
nile.fcast <- meanf(Nile, h=10)plot(nile.fcast)
monthdays 23
monthdays Number of days in each season
Description
Returns number of days in each month or quarter of the observed time period.
Usage
monthdays(x)
Arguments
x time series
Details
Useful for month length adjustments
Value
Time series
Author(s)
Rob J Hyndman
Examples
par(mfrow=c(2,1))plot(ldeaths,xlab="Year",ylab="pounds",
main="Monthly deaths from lung disease (UK)")ldeaths.adj <- ldeaths/monthdays(ldeaths)*365.25/12plot(ldeaths.adj,xlab="Year",ylab="pounds",
main="Adjusted monthly deaths from lung disease (UK)")
na.interp Interpolate missing values in a time series
Description
Uses linear interpolation to replace missing values.
Usage
na.interp(x)
24 ndiffs
Arguments
x time series
Details
Value
Time series
Author(s)
Rob J Hyndman
Examples
data(gold)plot(na.interp(gold))
ndiffs Number of differences
Description
Uses a KPSS test for the null hypothesis that x has a stationary root against a unit-root alternative.Returns the least number of differences required to pass the test at the level alpha.
Usage
ndiffs(x,alpha=0.05)
Arguments
x A univariate time series
alpha Level of the test
Value
An integer.
Author(s)
Rob J Hyndman
See Also
kpss.test
plot.ets 25
Examples
ndiffs(WWWusage)
plot.ets Plot components from ETS model
Description
Produces a plot of the level, slope and seasonal components from an ETS model.
Usage
## S3 method for class 'ets':plot(x, ...)
Arguments
x Object of class “ets”.
... Other plotting parameters passed to par.
Value
None. Function produces a plot
Author(s)
Rob J Hyndman
See Also
ets
Examples
fit <- ets(USAccDeaths)plot(fit)plot(fit,plot.type="single",ylab="",col=1:3)
26 rwf
rwf Random Walk Forecast
Description
Returns forecasts and prediction intervals for a random walk with drift model applied to x.
Usage
rwf(x, h=10, drift=FALSE, conf=c(80,95), fan=FALSE)
Arguments
x a numeric vector or time series
h Number of periods for forecasting
drift Logical flag. If TRUE, fits a random walk with drift model.
conf Confidence levels for prediction intervals.
fan If TRUE, conf is set to seq(50,99,by=1). This is suitable for fan plots.
Details
The random walk with drift model is
Yt = c + Yt−1 + Zt
where Zt is a normal iid error. Forecasts are given by
Yn(h) = ch + Yn
. If there is no drift, the drift parameter c=0. Forecast standard errors allow for uncertainty inestimating the drift parameter.
Value
An object of class "forecast".
The function summary is used to obtain and print a summary of the results, while the functionplot produces a plot of the forecasts and prediction intervals.
The generic accessor functions fitted.values and residuals extract useful features of thevalue returned by rwf.
An object of class "forecast" is a list containing at least the following elements:
model A list containing information about the fitted model
method The name of the forecasting method as a character string
mean Point forecasts as a time series
lower Lower limits for prediction intervals
seasadj 27
upper Upper limits for prediction intervals
conf The confidence values associated with the prediction intervals
x The original time series (either object itself or the time series used to createthe model stored as object).
residuals Residuals from the fitted model. That is x minus fitted values.
fitted Fitted values (one-step forecasts)
Author(s)
Rob J Hyndman
See Also
arima, meanf
Examples
gold.fcast <- rwf(gold[1:60],h=50)plot(gold.fcast)
seasadj Seasonal adjustment
Description
Returns seasonally adjusted data constructed by removing the seasonal component.
Usage
seasadj(object)
Arguments
object Object created by decompose or stl.
Value
Univariate time series.
Author(s)
Rob J Hyndman
See Also
stl, decompose
28 seasonaldummy
Examples
plot(AirPassengers)lines(seasadj(decompose(AirPassengers,"multiplicative")),col=4)
seasonaldummy Seasonal dummy variables
Description
Returns matrix of dummy variables suitable for use in arima, lm or arima.predict. The lastseason is omitted and used as the control.
Usage
seasonaldummy(x)seasonaldummyf(x,h)
Arguments
x Seasonal time series
h Number of periods ahead to forecast
Value
Numerical matrix with number of rows equal to the length(x) and number of columns equal tofrequency(x)-1.
Author(s)
Rob J Hyndman
Examples
plot(ldeaths)plot(ldeaths)month <- seasonaldummy(ldeaths)deaths.lm <- lm(ldeaths ~ month)tsdisplay(residuals(deaths.lm))ldeaths.fcast <- predict(deaths.lm,
data.frame(month=I(seasonaldummyf(ldeaths,36))),se.fit=TRUE)
seasonplot 29
seasonplot Seasonal plot
Description
Plots a seasonal plot as described in Makridakis, Wheelwright and Hyndman (1998, chapter 2).
Usage
seasonplot(x, s, season.labels = NULL, year.labels = FALSE,year.labels.left = FALSE, type = "o", main, ylab = "",xlab = NULL, col = 1, ...)
Arguments
x a numeric vector or time series.
s seasonal frequency of xseason.labels
Labels for each season in the "year"
year.labels Logical flag indicating whether labels for each year of data should be plotted onthe right.
year.labels.leftLogical flag indicating whether labels for each year of data should be plotted onthe left.
type plot type (as for plot)
main Main title.
ylab Y-axis label
xlab X-axis label
col Colour
... additional arguments to plot.
Value
None.
Author(s)
Rob J Hyndman
References
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, Wiley:New York.
30 ses
See Also
monthplot
Examples
seasonplot(AirPassengers)
ses Exponential smoothing forecasts
Description
Returns forecasts and other information for exponential smoothing forecasts applied to x.
Usage
ses(x, h=10, conf=c(80,95), fan=FALSE, ...)
holt(x, h=10, damped=FALSE, conf=c(80,95), fan=FALSE, ...)
hw(x, h=2*frequency(x), seasonal="additive", damped=FALSE, conf=c(80,95), fan=FALSE, ...)
Arguments
x a numeric vector or time series
h Number of periods for forecasting.
damped If TRUE, use a damped trend.
seasonal Type of seasonality in hw model. "additive" or "multiplicative"
conf Confidence level for prediction intervals.
fan If TRUE, conf is set to seq(50,99,by=1). This is suitable for fan plots.
... Other arguments passed to ets.
Details
ses, holt and hw are simply convenient wrapper functions for forecast(ets(...)).
Value
An object of class "forecast".
The function summary is used to obtain and print a summary of the results, while the functionplot produces a plot of the forecasts and prediction intervals.
The generic accessor functions fitted.values and residuals extract useful features of thevalue returned by ets and associated functions.
An object of class "forecast" is a list containing at least the following elements:
simulate.ets 31
model A list containing information about the fitted model
method The name of the forecasting method as a character string
mean Point forecasts as a time series
lower Lower limits for prediction intervals
upper Upper limits for prediction intervals
conf The confidence values associated with the prediction intervals
x The original time series (either object itself or the time series used to createthe model stored as object).
residuals Residuals from the fitted model. That is x minus fitted values.
fitted Fitted values (one-step forecasts)
Author(s)
Rob J Hyndman
References
Hyndman, R.J., Koehler, A.B., Snyder, R.D., Grose, S. (2002) "A state space framework for auto-matic forecasting using exponential smoothing methods", International J. Forecasting, 18(3), 439–454.
Hyndman, R.J., Akram, Md., and Archibald, B. (2003) "The admissible parameter space for expo-nential smoothing models". Working paper, Department of Econometrics and Business Statistics,Monash University.
See Also
ets, HoltWinters, rwf, arima.
Examples
fcast <- holt(airmiles)plot(fcast)deaths.fcast <- hw(USAccDeaths,h=48)plot(deaths.fcast)
simulate.ets Simulation from an ETS model
Description
Returns a time series based on the model object object.
Usage
simulate.ets(object, nsim=length(object$x), seed=NULL, initstate=object$state[1,], bootstrap=TRUE, ...)
32 sindexf
Arguments
object An object of class "ets". Usually the result of a call to ets.
nsim Number of periods for the simulated series
seed Either NULL or an integer that will be used in a call to set.seed beforesimulating the time seriers. The default, NULL will not change the randomgenerator state.
initstate State at time 0.
bootstrap If TRUE, simulation uses resampled errors rather than normally distributed er-rors.
... Other arguments.
Value
An object of class "ts".
Author(s)
Rob J Hyndman
See Also
ets
Examples
fit <- ets(USAccDeaths)plot(simulate(fit, 100))
sindexf Forecast seasonal index
Description
Returns vector containing the seasonal index for h future periods. If the seasonal index is non-periodic, it uses the last values of the index.
Usage
sindexf(object, h)
Arguments
object Output from decompose or stl.
h Number of periods ahead to forecast
splinef 33
Value
Time series
Author(s)
Rob J Hyndman
Examples
uk.stl <- stl(UKDriverDeaths,"periodic")uk.sa <- seasadj(uk.stl)uk.fcast <- holt(uk.sa,36)seasf <- sindexf(uk.stl,36)uk.fcast$mean <- uk.fcast$mean + seasfuk.fcast$lower <- uk.fcast$lower + cbind(seasf,seasf)uk.fcast$upper <- uk.fcast$upper + cbind(seasf,seasf)uk.fcast$x <- UKDriverDeathsplot(uk.fcast,main="Forecasts from Holt's method with seasonal adjustment")
splinef Cubic Spline Forecast
Description
Returns local linear forecasts and prediction intervals using cubic smoothing splines.
Usage
splinef(x, h=10, conf=c(80,95), fan=FALSE)
Arguments
x a numeric vector or time series
h Number of periods for forecasting
conf Confidence level for prediction intervals.
fan If TRUE, conf is set to seq(50,99,by=1). This is suitable for fan plots.
Details
The cubic smoothing spline model is equivalent to an ARIMA(0,2,2) model but with a restrictedparameter space. The advantage of the spline model over the full ARIMA model is that it providesa smooth historical trend as well as a linear forecast function. Hyndman, King, Pitrun, and Bil-lah (2002) show that the forecast performance of the method is hardly affected by the restrictedparameter space.
34 splinef
Value
An object of class "forecast".
The function summary is used to obtain and print a summary of the results, while the functionplot produces a plot of the forecasts and prediction intervals.
The generic accessor functions fitted.values and residuals extract useful features of thevalue returned by meanf.
An object of class "forecast" is a list containing at least the following elements:
model A list containing information about the fitted model
method The name of the forecasting method as a character string
mean Point forecasts as a time series
lower Lower limits for prediction intervals
upper Upper limits for prediction intervals
conf The confidence values associated with the prediction intervals
x The original time series (either object itself or the time series used to createthe model stored as object).
residuals Residuals from the fitted model. That is x minus fitted values.
fitted Fitted values (one-step forecasts)
Author(s)
Rob J Hyndman
References
Hyndman, King, Pitrun and Billah (2002) Local linear forecasts using cubic smoothing splines.Working paper available at http://www-personal.buseco.monash.edu.au/~hyndman/papers/splinefcast.htm.
See Also
smooth.spline, arima, holt.
Examples
fcast <- splinef(uspop,h=5)plot(fcast)summary(fcast)
thetaf 35
thetaf Theta method forecast
Description
Returns forecasts and prediction intervals for a theta method forecast.
Usage
thetaf(x, h=10, conf=c(80,95), fan=FALSE)
Arguments
x a numeric vector or time series
h Number of periods for forecasting
conf Confidence levels for prediction intervals.
fan If TRUE, conf is set to seq(50,99,by=1). This is suitable for fan plots.
Details
The theta method of Assimakopoulos and Nikolopoulos (2000) is equivalent to simple exponentialsmoothing with drift. This is demonstrated in Hyndman and Billah (2003). Prediction intervals arecomputed using the underlying state space model.
Value
An object of class "forecast".
The function summary is used to obtain and print a summary of the results, while the functionplot produces a plot of the forecasts and prediction intervals.
The generic accessor functions fitted.values and residuals extract useful features of thevalue returned by rwf.
An object of class "forecast" is a list containing at least the following elements:
model A list containing information about the fitted model
method The name of the forecasting method as a character string
mean Point forecasts as a time series
lower Lower limits for prediction intervals
upper Upper limits for prediction intervals
conf The confidence values associated with the prediction intervals
x The original time series (either object itself or the time series used to createthe model stored as object).
residuals Residuals from the fitted model. That is x minus fitted values.
fitted Fitted values (one-step forecasts)
36 tsdisplay
Author(s)
Rob J Hyndman
References
Assimakopoulos, V. and Nikolopoulos, K. (2000). The theta model: a decomposition approach toforecasting. International Journal of Forecasting 16, 521-530.
Hyndman, R.J., and Billah, B. (2003) Unmasking the Theta method. International J. Forecasting,19, 287-290.
See Also
arima, meanf, rwf, ses
Examples
nile.fcast <- thetaf(Nile)plot(nile.fcast)
tsdisplay Time series display
Description
Plots a time series along with its acf and either its pacf, lagged scatterplot or spectrum.
Usage
tsdisplay(x, plot.type = "partial", points = TRUE, ci.type ="white", lag.max = round(10 * log10(length(x))),na.action = na.interp, main = NULL, ylab = "", xlab ="", pch = 1, cex = 0.5, ...)
Arguments
x a numeric vector or time series.
plot.type type of plot to include in lower right corner. Possible values are "partial", "scat-ter" or "spectrum".
points logical flag indicating whether to show the individual points or not in the timeplot.
ci.type type of confidence limits for ACF. Possible values are as for acf.
lag.max the maximum lag to plot for the acf and pacf.
na.action how to handle missing values. Default is to use linear interpolation.
main Main title.
ylab Y-axis label
wineind 37
xlab X-axis labelpch Plotting charactercex Character size... additional arguments to acf.
Value
None.
Author(s)
Rob J Hyndman
References
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, Wiley:New York.
See Also
plot.ts, acf
Examples
tsdisplay(diff(WWWusage))
wineind Australian total wine sales
Description
Australian total wine sales by wine makers in bottles <= 1 litre. Jan 1980 – Aug 1994.
Usage
wineind
Format
Time series data
Source
Time Series Data Library. http://www-personal.buseco.monash.edu.au/~hyndman/TSDL/
Examples
tsdisplay(wineind)
38 woolyrnq
woolyrnq Quarterly production of woollen yarn in Australia
Description
Quarterly production of woollen yarn in Australia: tonnes. Mar 1965 – Sep 1994.
Usage
woolyrnq
Format
Time series data
Source
Time Series Data Library. http://www-personal.buseco.monash.edu.au/~hyndman/TSDL/
Examples
tsdisplay(woolyrnq)
Package ‘fma’
Title Data sets from “Forecasting: methods and applications” by Makridakis, Wheelwright &Hyndman (1998)
Description All data sets from “Forecasting: methods and applications” by Makridakis, Wheelwright& Hyndman (Wiley, 3rd ed., 1998).
advert Sales and advertising expenditure
Description
Monthly sales and advertising expenditure for an automotive parts company.
Usage
advert
Format
Data frame containing the following columns:
advert Monthly Advertising expenditure
sales Monthly sales volume
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 6.7. Exercise 8.1.
Examples
plot(sales ~ advert, data=advert)
39
40 airpass
advsales Sales volume and advertising expenditure
Description
Sales volume and advertising expenditure for a dietary weight control product.
Usage
advsales
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 8.
References
Blattberg and Jeuland (1981).
Examples
plot(advsales)
airpass Monthly Airline Passenger Numbers 1949-1960
Description
The classic Box & Jenkins airline data. Monthly totals of international airline passengers (1949–1956).
Usage
airpass
Format
A monthly time series, in thousands.
auto 41
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 2.4, Chapter 3, Exercise 4.7.
References
Box, Jenkins and Reinsell (1994) Time series analysis: forecasting and control, 3rd edition, Holden-Day: San Francisco. Series G.
Examples
plot(airpass)seasonplot(airpass)tsdisplay(airpass)
auto Attributes of some US and Japanese automobiles
Description
Price, mileage, age and country of origin for 45 automobiles.
Usage
auto
Format
This data frame contains the following columns:
Model Name of modelCountry Country of manufactureMileage Mileage per gallonPrice Price of car at time of measurement
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, Wiley:New York. Chapter 2.
References
Consumer Reports, April 1990, pp.235-255.
Examples
plot(Price ~ Mileage, data=auto,pch=19,col=2)points(auto$Mileage[auto$Country=="USA"],auto$Price[auto$Country=="USA"],pch=19,col=4)legend(30,25000,legend=c("USA","Japan"),pch=19,col=c(4,2))
42 beer
bank Mutual savings bank deposits
Description
Deposits in a mutual savings bank in a large metropolitan area.
Usage
bank
Format
Data frame containing the following columns:
EOM End of month balance
AAA Composite AAA bond rates
threefour US Government 3-4 year bonds
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 6.
Examples
plot(bank)
beer Monthly beer production
Description
Monthly Australian beer production: Jan 1991 – Aug 1995.
Usage
beer
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 2.
bicoal 43
Examples
plot(beer)seasonplot(beer)tsdisplay(beer)
bicoal Annual bituminous coal production
Description
Annual bituminous coal production in the USA: 1920–1968.
Usage
bicoal
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 7.7.
Examples
tsdisplay(bicoal)
books Sales of paperback and hardcover books
Description
Daily sales of paperback and hardcover books at the same store.
Usage
books
Format
Bivariate time series containing the following columns:
Paperback Number of paperback sales each day
Hardcover Number of hardcover sales each day
44 boston
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 4.5.
Examples
plot(books)
boston Monthly dollar volume of sales
Description
Monthly dollar volume of sales on Boston stock exchange and combined New York and Americanstock exchange. January 1967 – November 1969.
Usage
boston
Format
Bivariate time series containing the following columns:
nyase New York and American Stock Exchange dollar volume
bse Boston Stock Exchange dollar volume
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 6.5
References
McGee and Carleton (1970) Piecewise regression, Journal of the American Statistical Association,65, 1109–1124.
Examples
plot(boston)
bricksq 45
bricksq Quarterly clay brick production
Description
Australian quarterly clay brick production: 1956–1994.
Usage
bricksq
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 1 and Exercise 2.3.
Examples
plot(bricksq)seasonplot(bricksq)tsdisplay(bricksq)
canadian Canadian unemployment rate
Description
Canadian unemployment rate as a percentage of the civilian labor force between 1974 and the thirdquarter of 1975.
Usage
canadian
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 4.1.
46 cement
Examples
plot(canadian)
capital Quarterly capital expenditure and appropriations
Description
Seasonally adjusted quarterly capital expenditure and appropriations in U.S. manufacturing: 1953–1974.
Usage
capital
Format
Bivariate time series containing the following columns:
capital Quarterly capital expenditure for US manufacturing.
appropriations Quarterly capital appropriations for US manufacturing.
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 8.
Examples
plot(capital)
cement Cement composition and heat data
Description
Cement composition and heat data.
Usage
cement
chicken 47
Format
Data frame containing the following columns:
pc1 Percentage by weight of component 1
pc2 Percentage by weight of component 2
pc3 Percentage by weight of component 3
heat Heat emitted in calories per gram of cement.
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 6.4
Examples
plot(cement)
chicken Price of chicken
Description
Price of chicken in US (constant dollars): 1924–1993.
Usage
chicken
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 9.
Examples
plot(chicken)
48 copper
condmilk Condensed milk
Description
Manufacturer’s Stocks of evaporated and sweetened condensed milk.
Usage
condmilk
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 7.5.
Examples
plot(condmilk)seasonplot(condmilk)tsdisplay(condmilk)
copper Copper price
Description
Yearly copper prices, 1800–1997 (in constant 1997 dollars).
Usage
copper
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 9.
Examples
plot(copper)
copper1 49
copper1 Copper prices
Description
Monthly copper prices for 28 consecutive months (in constant 1997 dollars).
Usage
copper1
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 9.
Examples
plot(copper1)
copper2 Copper prices
Description
Yearly copper prices for 14 consecutive years (in constant 1997 dollars).
Usage
copper2
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 9.
Examples
plot(copper2)
50 cowtemp
copper3 Copper prices
Description
Yearly copper prices for 43 consecutive years (in constant 1997 dollars).
Usage
copper3
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 9.
Examples
plot(copper3)
cowtemp Temperature of a cow
Description
Daily morning temperature of a cow. Measure at 6.30am for 75 consecutive mornings by countingchirps from a telemetric thermometer implanted in the cow. Data are chirps per 5-minute intervalminus 800.
Usage
cowtemp
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercises 2.3 and 2.4.
cpimel 51
References
Velleman, Paul. (1981) The ABC of EDA, Duxbury Press.
Examples
plot(cowtemp)tsdisplay(cowtemp)
cpimel Consumer price index
Description
Quarterly CPI (consumer price index) for Victoria: Q1 1980 to Q2 1995.
Usage
cpimel
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 8.7.
Examples
tsdisplay(cpimel)
dexter Dexterity test and production ratings
Description
Scores on manual dexterity test and production ratings for 20 workers.
Usage
dexter
52 dj
Format
Data frame containing the following columns:
score Test score for manual dexterity
production Production rating
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 5.4
Examples
plot(production~score,data=dexter,pch=19,col=3)
dj Dow-Jones index
Description
Dow-Jones index on 251 trading days ending 26 Aug 1994.
Usage
dj
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 7.
References
Brockwell and Davis (1996)
Examples
tsdisplay(dj)
dole 53
dole Unemployment benefits in Australia
Description
Monthly total of people on unemployment benefits in Australia (Jan 1965 – Jul 1992).
Usage
dole
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 2.3.
Examples
plot(dole)tsdisplay(dole)
dowjones Dow-Jones index
Description
Dow-Jones index, 28 Aug - 18 Dec 1972.
Usage
dowjones
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 2.7.
Examples
tsdisplay(dowjones)
54 eggs
econsumption Electricity consumption and temperature
Description
Electricity consumption and maximum temperature for 12 randomly chosen days.
Usage
temperature
Format
Data frame containing the following columns:
Mwh Daily electricity consumption (megawatt-hours)
temp Daily maximum temperature (degrees Celsius)
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 5.5
Examples
plot(Mwh ~ temp, data=econsumption,pch=19,col=4)
eggs Price of eggs
Description
Price of dozen eggs in US, 1900–1993, in constant dollars.
Usage
eggs
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 9.
eknives 55
Examples
plot(eggs)
eknives Sales of electric knives
Description
Sales of electric knives: Jan 1991 - April 1992.
Usage
eknives
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 4.2.
Examples
plot(eknives)
elco Sales of Elco’s laser printers
Description
Sales of Elco’s laser printers: 1992–1998.
Usage
elco
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 10.
56 expenditure
Examples
plot(elco)
elec Electricity production
Description
Australian monthly electricity production: Jan 1956 – Aug 1995.
Usage
elec
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapters 1–2, 7.
Examples
plot(elec)seasonplot(elec)tsdisplay(elec)
expenditure Expenditure
Description
Expenditure for 12 supermarket customers.
Usage
expenditure
Format
Time series data
fancy 57
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 2.
Examples
hist(expenditure)
fancy Sales for a souvenir shop
Description
Monthly sales for a souvenir shop on the wharf at a beach resort town in Queensland, Australia.
Usage
fancy
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 5.8.
Examples
plot(fancy)seasonplot(fancy)
french Industry index
Description
French index of industry.
Usage
french
Format
Time series data
58 housing
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 4.4.
Examples
plot(french)
housing Housing data
Description
Monthly housing starts, construction contracts and average new home mortgage rates (Jan 1983 -Oct 1989).
Usage
housing
Format
Trivariate time series containing the following columns:
hstarts Monthly housing starts (thousands of units)
construction Construction contracts (millions of dollars)
interest Average new home mortgage rates
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 8.
References
Survey of current business, US Department of Commerce, 1990.
Examples
plot(housing)
hsales 59
hsales Sales of one-family houses
Description
Monthly sales of new one-family houses sold in the USA since 1973.
Usage
hsales
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 3.
References
US Census Bureau, Manufacturing and Construction Division
Examples
plot(hsales)plot(stl(hsales,"periodic"),main="Sales of new one-family houses, USA")
hsales2 Sales of new one-family houses
Description
Sales of new one-family houses in the USA (Jan 1987 – Nov 1995).
Usage
hsales2
Format
Time series data
60 ibm
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 7.10.
Examples
plot(hsales2)seasonplot(hsales2)tsdisplay(hsales2)
huron Level of Lake Huron
Description
Level of Lake Huron in feet (reduced by 570 feet): 1875–1972.
Usage
huron
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 8.2.
Examples
plot(huron)
ibm IBM sales and profit
Description
IBM sales and profit (1954-1984) and forecasts.
Usage
ibm
ibmclose 61
Format
Time series data
Sales IBM annual sales
Profit IBM annual profit
FSales Forecast of IBM sales made in 1984
FProfit Forecast of IBM profits made in 1984
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 9.
Examples
par(mfrow=c(2,1))plot(ibm[,1],xlim=c(1954,2000),ylim=c(0,200),
ylab="Sales (billions of $)",xlab="Year",type="o")lines(ibm[,3],col=2,type="o")plot(ibm[,2],xlim=c(1954,2000),ylim=c(-10,30),
ylab="Profits (billions of $)",xlab="Year",type="o")lines(ibm[,4],col=2,type="o")
ibmclose Closing IBM stock price
Description
Daily closing IBM stock price.
Usage
ibmclose
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 7.2.
References
Box, Jenkins and Reinsell (1994) Time series analysis: forecasting and control, 3rd edition, Holden-Day: San Francisco.
62 internet
Examples
tsdisplay(ibmclose)
input Input series
Description
Input series for exercise 8.6.
Usage
input
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 8.6.
Examples
plot(input)
internet Number of internet users
Description
Number of users logged on to an internet server each minute over a 100-minute period.
Usage
internet
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 7.
invent15 63
Examples
tsdisplay(internet)
invent15 Inventory demand
Description
Inventory demand for product E15.
Usage
invent15
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 2.6. Also Chapter 4.
Examples
plot(invent15)
jcars Motor vehicle production
Description
Japanese motor vehicle production in thousand (1947–1989).
Usage
jcars
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 2.8. Chapter 8.
64 kkong
References
World motor vehicle data, Motor Vehicle Manufacturers of US Inc, Detroit, 1991.
Examples
plot(jcars)log.jcars <- BoxCox(jcars,0)jcars.f <- holt(log.jcars)plot(jcars.f)
kkong King Kong data
Description
King Kong data.
Usage
kkong
Format
Data frame consisting of following columns
weight Weights of 21 gorillas
height Heights of 21 gorillas
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 5. Exercise 5.6.
Examples
plot(weight~height,data=kkong,pch=19,col=2)
labour 65
labour Civilian labour force
Description
Number of persons in the civilian labour force in Australia each month (Feb 1978 - Aug 1995).
Usage
labour
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 3.8.
Examples
plot(labour)labour.stl <- stl(labour,10)plot(labour.stl)monthplot(labour.stl$time.series[,1],type="h")
lynx Annual Canadian Lynx trappings 1821–1934
Description
Annual number of lynx trapped in McKenzie river district of northwest Canada: 1821–1934.
Usage
lynx
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 2.3.
66 milk
References
Campbell, M. J.and A. M. Walker (1977). A Survey of statistical work on the Mackenzie Riverseries of annual Canadian lynx trappings for the years 1821–1934 and a new analysis. Journal ofthe Royal Statistical Society series A, 140, 411–431.
Examples
plot(lynx)tsdisplay(lynx)
milk Monthly milk production per cow
Description
Average monthly milk production per cow over 14 years.
Usage
milk
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 2.
References
Cryer (1986) Time series analysis, Duxbury Press: Belmont.
Examples
par(mfrow=c(2,1))plot(milk,xlab="Year",ylab="pounds",
main="Monthly milk production per cow")milk.adj <- milk/monthdays(milk)*365.25/12plot(milk.adj,xlab="Year",ylab="pounds",
main="Adjusted monthly milk production per cow")
mink 67
mink Number of minks trapped
Description
Annual number of minks trapped in McKenzie river district of northwest Canada: 1848–1911.
Usage
mink
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 2.4.
Examples
tsdisplay(mink)
mortal Mortality
Description
Bird mortality for 156 poultry farms, Aug 1995 - Jul 1996.
Usage
mortal
Format
Data frame containing the following columns:
typeA Percentage of Type A birds for each farm.
mortality Percentage mortality of all birds for each farm.
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 5.9
68 motion
Examples
plot(mortality~typeA,data=mortal)
motel Total accommodation at hotel, motel and guest house
Description
Total room nights occupied and total monthly takings from accommodation at hotel, motel andguest house in Victoria, Australia: Jan 1980 - June 1995.
Usage
motel
Format
Trivariate time series containing the following columns:
Roomnights Total room nights
Takings Total monthly takings (thousands of dollars)
CPI Quarterly CPI values
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 8.7.
Examples
plot(motel[,2],motel[,1], xlab="Room nights", ylab="Takings",pch=19,col=4)
motion Employment figures in the motion picture industry
Description
Monthly employment figures for the motion picture industry (SIC Code 78): Jan 1955 – Dec 1970.
Usage
motion
Format
Time series data
nail 69
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 7.9.
References
"Employment and earnings, US 1909–1978", Department of Labor, 1979.
Examples
plot(motion)seasonplot(motion)tsdisplay(motion)
nail Nail prices
Description
Nail prices, 1800–1996 in constant dollars.
Usage
nail
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 9.
Examples
plot(nail)
70 olympic
oilprice Oil prices
Description
Oil prices in constant 1997 dollars: 1870–1997.
Usage
oilprice
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 10.
Examples
plot(oilprice)
olympic Men’s 400 m final winning times in each Olympic Games
Description
Winning times for the men’s 400 m final in each Olympic Games: 1896–1996.
Usage
olympic
Format
Data frame containing the following columns:
Year Year of Olympics
time Winning time in 400m final
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 5.7
ozone 71
Examples
plot(time~Year,data=olympic,pch=19,col=3)
ozone Ozone depletion and melanoma rates
Description
Ozone depletion and melanoma rates in various locations.
Usage
ozone
Format
Data frame containing the following columns:
ozonedep Ozone depletion rates as percentages
melanoma Melanoma rates as percentages
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 5.3.
Examples
plot(ozonedep~melanoma,data=ozone,pch=19,col=2)
paris Average temperature
Description
Average monthly temperature in Paris.
Usage
paris
Format
Time series data
72 pcv
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 2.1.
Examples
plot(paris)seasonplot(paris)tsdisplay(paris)
pcv GDP
Description
GDP for Western Europe and PCV industry sales.
Usage
pcv
Format
Bivariate time series consisting of the following columns
GDP GDP Western Europe
PCV PCV Industry sales
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 5.
Examples
plot(PCV~GDP,data=pcv,pch=20,col=2)
petrol 73
petrol Sales of petroleum and related product
Description
US monthly sales of petroleum and related product: Jan 1971 - Dec 1991.
Usage
petrol
Format
Multivariate time series data:
Chemicals Sales of chemicals and allied products
Coal Sales of Bituminous coal products
Petrol Sales of petroleum and coal products
Vehicles Sales of motor vehicles and parts
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 8.
Examples
plot(petrol)
pigs Number of pigs slaughtered
Description
Monthly total number of pigs slaughtered in Victoria, Australia (Jan 1980 – Aug 1995).
Usage
pigs
Format
Time series data
74 pollution
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 7.
Examples
tsdisplay(pigs)
plastics Sales of plastic product
Description
Monthly sales of product A for a plastics manufacturer.
Usage
plastics
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 3.5.
Examples
plot(plastics)seasonplot(plastics)plot(stl(plastics,"periodic"))
pollution Shipment of pollution equipment
Description
Monthly shipments of pollution equipment (in thousands of French francs), Jan 1986 – Oct 1996.
Usage
pollution
productC 75
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 7.
Examples
tsdisplay(pollution)
productC Sales of product C
Description
Sales of product C (a lubricant sold in large containers).
Usage
productC
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 1.
Examples
plot(productC)
76 qelec
pulpprice Pulp price and shipments
Description
World pulp price and shipments.
Usage
pulpprice
Format
Data frame consisting of following columns
shipments World pulp shipments
price World pulp price
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 5.
Examples
plot(shipments~price,data=pulpprice)
qelec Electricity production
Description
Quarterly electricity production.
Usage
qelec
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 3.4.
qsales 77
Examples
plot(decompose(qelec))
qsales Sales data
Description
Quarterly exports of a French company in thousands of francs.
Usage
qsales
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 3.7 and Table 4-7.
Examples
plot(qsales)
running Running times and maximal aerobic capacity
Description
Running times and maximal aerobic capacity for 14 female runners.
Usage
running
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 2.5.
78 schizo
References
Conley, Krahenbuhl, Burkett and Millar (1981) Physiological correlates of female road racing per-formance, Research Quarterly Exercise Sport, 52, 441–448.
Examples
plot(times~capacity,data=running,pch=19,col=2)
sales Sales data
Description
Sales data over 10 time periods.
Usage
sales
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 5.
Examples
plot(sales,type="p")abline(lsfit(1:10,sales))
schizo Perceptual speed scores
Description
Daily perceptual speed scores for a schizophrenic patient. The patient began receiving a powerfultranquilizer (chlorpromzaine) on the 61st day and continued receiving the drug for the remainder ofthe sample period. It is expected that this drug would reduce perceptual speed.
Usage
schizo
shampoo 79
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 8.8.
References
McCleary and Hay (1980).
Examples
plot(schizo)
shampoo Sales of shampoo
Description
Sales of shampoo over a three year period.
Usage
shampoo
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 3.
Examples
plot(shampoo)
80 ship
sheep Sheep population
Description
Sheep population (in millions) of England and Wales: 1867–1939.
Usage
sheep
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 7.6.
References
Kendall (1976).
Examples
tsdisplay(sheep)
ship Electric can opener shipments
Description
Electric can opener shipments.
Usage
ship
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 4. Exercise 4.6.
shipex 81
Examples
plot(ship)
shipex Shipments
Description
Shipments
Usage
shipex
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 3.1
Examples
plot(shipex)
strikes Number of strikes
Description
Number of strikes in the US from 1951 to 1980.
Usage
strikes
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 7.4
82 texasgas
References
Brockwell and Davis (1991)
Examples
tsdisplay(strikes)
telephone Telephone cost
Description
Telephone cost in San Francisco, New York: 1915–1996.
Usage
telephone
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 9.
Examples
plot(telephone)
texasgas Price and consumption of natural gas
Description
Price and per capita consumption of natural gas in 20 towns in Texas.
Usage
texasgas
Format
Data frame containing the following columns:
price Average price in cents per thousand cubic feetconsumption Consumption per customer in thousand cubic feet.
ukdeaths 83
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 5.10. Exercise 6.2.
Examples
plot(consumption ~ price, data=texasgas)
ukdeaths Total deaths and serious injuries
Description
Monthly total deaths and serious injuries on UK roads: Jan 1975 – Dec 1984. In February 1983,new legislation came into force requiring seat belts to be worn.
Usage
ukdeaths
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 8.
References
Harvey (1989)
Examples
plot(ukdeaths)seasonplot(ukdeaths)tsdisplay(ukdeaths)
84 uselec
usdeaths Accidental deaths in USA
Description
Monthly accidental deaths in USA.
Usage
usdeaths
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercises 2.3 and 2.4.
Examples
plot(usdeaths)seasonplot(usdeaths)tsdisplay(usdeaths)
uselec Total generation of electricity
Description
Monthly total generation of electricity by the U.S. electric industry (Jan 1985 - Oct 1996.
Usage
uselec
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 7.8.
ustreas 85
Examples
plot(uselec)seasonplot(uselec)tsdisplay(uselec)
ustreas Treasury bill contracts
Description
US treasury bill contracts on the Chicago market for 100 consecutive trading days in 1981.
Usage
ustreas
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 1.
Examples
plot(ustreas)tsdisplay(ustreas)
wagesuk Real daily wages
Description
Real daily wages in pound, England: 1260–1994.
Usage
wagesuk
Format
Time series data
86 wn
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 9.
Examples
plot(wagesuk)
wheat Wheat prices
Description
Wheat prices in constant 1996 pounds: 1264–1996.
Usage
wheat
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 9.
Examples
plot(wheat)
wn White noise series
Description
White noise series.
Usage
wn
Format
Time series data
wnoise 87
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Exercise 7.3.
Examples
tsdisplay(wn)
wnoise White noise time series
Description
White noise time series with 36 values.
Usage
wnoise
Format
Time series data
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chpater 7.
Examples
tsdisplay(wnoise)
writing Sales of printing and writing paper
Description
Industry sales for printing and writing paper (in thousands of French francs): Jan 1963 – Dec 1972.
Usage
writing
Format
Time series data
88 writing
Source
Makridakis, Wheelwright and Hyndman (1998) Forecasting: methods and applications, John Wiley& Sons: New York. Chapter 7.
Examples
tsdisplay(writing)seasonplot(writing)
Package ‘Mcomp’
Title Data from the M-competitions
Description The 1001 time series from the M-competition (Makridakis et al. 1982) and the 3003 timeseries from the IJF-M3 competition (Makridakis and Hibon, 2000).
M1 M-Competition data
Description
The time series from the M1 and M3 forecasting competitions.
Usage
data(M1)data(M3)
Format
M1 is a list of 1001 series and M3 is a list of 3003 series. Each list is of class Mcomp. Each serieswithin M1 and M3 is of class Mdata with the following structure:
sn Name of the series
st Series number and period. For example "Y1" denotes first yearly series, "Q20" denotes 20thquarterly series and so on.
n The number of observations in the time series
h The number of required forecasts
period Interval of the time series. Possible values are "YEARLY", "QUARTERLY", "MONTHLY"& "OTHER".
type The type of series. Possible values for M1 are "DEMOGR", "INDUST", "MACRO1", "MACRO2","MICRO1", "MICRO2" & "MICRO3". Possible values for M3 are "DEMOGRAPHIC", "FI-NANCE", "INDUSTRY", "MACRO", "MICRO", "OTHER".
description A short description of the time series
x A time series of length n (the historical data)
xx A time series of length h (the future data)
89
90 plot.Mdata
Author(s)
Muhammad Akram and Rob Hyndman
Source
http://www.forecasters.org/data/tsdata.htm.
Detailed results from M3 competition at http://www-marketing.wharton.upenn.edu/forecast/m3-competition.html.
References
Makridakis, S., A. Andersen, R. Carbone, R. Fildes, M. Hibon, R. Lewandowski, J. Newton, E.Parzen, and R. Winkler (1982) The accuracy of extrapolation (time series) methods: results of aforecasting competition. Journal of Forecasting, 1, 111–153.
Makridakis and Hibon (2000) The M3-competition: results, conclusions and implications. Interna-tional Journal of Forecasting, 16, 451-476.
See Also
subset.Mcomp, plot.Mdata
Examples
M1plot(M1$YAF2)subset(M1,"monthly")
plot.Mdata Plotting M Competition data
Description
plot.Mdata plots a time series from the M competition data sets.
Usage
plot.Mdata(x, xlim=c(start(x$x)[1],end(x$xx)[1]), ylim=range(x$x,x$xx),main=x$sn, xlab="", ylab="", ...)
Arguments
x A series of M-competition data
xlim Limits on x-axis
ylim Limits on y-axis
main Main title
subset.Mcomp 91
xlab Label on x-axis
ylab Label on y-axis
... Other plotting arguments
Value
None. The function produces a time series plot of the selected series.
Author(s)
Muhammad Akram and Rob Hyndman
See Also
M1
Examples
plot(M1[[1]])plot(M1$YAF3)plot(M3$N0647)
subset.Mcomp Subset of time series from the M Competitions
Description
subset.Mcomp returns a subset of the time series data from the M Competitions. Subsets can befor specific periods, or specific types of data or both.
Usage
## S3 method for class 'Mcomp':subset(x, cond1, cond2, ...)
Arguments
x M-competition data or a subset of M-competition data
cond1 Type or period of the data. Type is a character variable and period could becharacter or numeric.
cond2 Optional second condition specifying type or period of the data, depending oncond1. If cond1 denotes type then cond2would denote period, but if cond1denotes period then cond2 would denote type.
... Other arguments.
92 subset.Mcomp
Details
Possible values for cond1 and cond2 denoting period are 1, 4, 12, "yearly", "quarterly", "monthly"and "other".
Possible values for cond1 and cond2 denoting type are "macro", "micro", "industry", "finance","demographic", "allother", "macro1", "macro2", "micro1", "micro2", "micro3". These correspondto the descriptions used in the competitions. See the references for details.
Partial matching used for both conditions.
Value
An object of class Mcomp consisting of the selected series.
Author(s)
Muhammad Akram and Rob Hyndman
References
Makridakis, S., A. Andersen, R. Carbone, R. Fildes, M. Hibon, R. Lewandowski, J. Newton, E.Parzen, and R. Winkler (1982) The accuracy of extrapolation (time series) methods: results of aforecasting competition. Journal of Forecasting, 1, 111–153.
Makridakis and Hibon (2000) The M3-competition: results, conclusions and implications. Interna-tional Journal of Forecasting, 16, 451-476.
See Also
M1
Examples
M3.quarterly <- subset(M3,4)M1.yearly.industry <- subset(M1,1,"industry")
Index
∗Topic datasetsadvert, 39advsales, 40airpass, 40auto, 41bank, 42beer, 42bicoal, 43books, 43boston, 44bricksq, 45canadian, 45capital, 46cement, 46chicken, 47condmilk, 48copper, 48copper1, 49copper2, 49copper3, 50cowtemp, 50cpimel, 51dexter, 51dj, 52dole, 53dowjones, 53econsumption, 54eggs, 54eknives, 55elco, 55elec, 56expenditure, 56fancy, 57french, 57gas, 19gold, 21housing, 58hsales, 59hsales2, 59
huron, 60ibm, 60ibmclose, 61input, 62internet, 62invent15, 63jcars, 63kkong, 64labour, 65lynx, 65M1, 89milk, 66mink, 67mortal, 67motel, 68motion, 68nail, 69oilprice, 70olympic, 70ozone, 71paris, 71pcv, 72petrol, 73pigs, 73plastics, 74pollution, 74productC, 75pulpprice, 76qelec, 76qsales, 77running, 77sales, 78schizo, 78shampoo, 79sheep, 80ship, 80shipex, 81strikes, 81telephone, 82
93
94 INDEX
texasgas, 82ukdeaths, 83usdeaths, 84uselec, 84ustreas, 85wagesuk, 85wheat, 86wineind, 37wn, 86wnoise, 87woolyrnq, 38writing, 87
∗Topic datasubset.Mcomp, 91
∗Topic hplotplot.ets, 25plot.Mdata, 90
∗Topic tsarima, 2arima.errors, 4best.arima, 5BoxCox, 1croston, 6ets, 8fitted.Arima, 10forecast, 13forecast.Arima, 10forecast.ets, 17forecast.HoltWinters, 12forecast.StructTS, 14forecasterrors, 16gof, 20meanf, 21monthdays, 23na.interp, 23ndiffs, 24plot.forecast, 18rwf, 26seasadj, 27seasonaldummy, 28seasonplot, 29ses, 30simulate.ets, 31sindexf, 32splinef, 33thetaf, 35tsdisplay, 36
acf, 36, 37
advert, 39advsales, 40airpass, 40ar, 11arima, 2, 2–4, 6, 9–11, 13, 27, 28, 31, 34, 36arima.errors, 4arima.predict, 28auto, 41auto.arima (best.arima), 5
bank, 42beer, 42best.arima, 5bicoal, 43books, 43boston, 44BoxCox, 1bricksq, 45
canadian, 45capital, 46cement, 46chicken, 47condmilk, 48copper, 48copper1, 49copper2, 49copper3, 50cowtemp, 50cpimel, 51croston, 6, 14
decompose, 27, 32dexter, 51dj, 52dole, 53dowjones, 53
econsumption, 54eggs, 54eknives, 55elco, 55elec, 56ets, 8, 12, 14, 17, 18, 25, 31, 32expenditure, 56
fancy, 57fitted.Arima, 10forecast, 13, 18
INDEX 95
forecast.ar (forecast.Arima), 10forecast.Arima, 2, 10, 10, 13, 14forecast.ets, 13, 14, 17forecast.HoltWinters, 12, 14forecast.StructTS, 14, 14forecast.ts, 13forecasterrors, 16, 20french, 57
gas, 19gof, 16, 20gold, 21
holt, 14, 34holt (ses), 30HoltWinters, 9, 12, 13, 31housing, 58hsales, 59hsales2, 59huron, 60hw, 14hw (ses), 30
ibm, 60ibmclose, 61input, 62internet, 62InvBoxCox, 18InvBoxCox (BoxCox), 1invent15, 63
jcars, 63
kkong, 64kpss.test, 5, 24
labour, 65lm, 28lynx, 65
M1, 89, 91, 92M3 (M1), 89meanf, 14, 21, 27, 36milk, 66mink, 67monthdays, 23monthplot, 30mortal, 67motel, 68motion, 68
na.interp, 23nail, 69ndiffs, 24
oilprice, 70olympic, 70ozone, 71
par, 25paris, 71pcv, 72petrol, 73pigs, 73plastics, 74plot, 19, 29plot.ets, 25plot.forecast, 18plot.Mdata, 90, 90plot.splineforecast
(plot.forecast), 18plot.ts, 19, 37pollution, 74predict.ar, 11predict.arima, 11predict.HoltWinters, 12, 13predict.StructTS, 15print.ets (ets), 8print.forecast (forecast), 13productC, 75pulpprice, 76
qelec, 76qsales, 77
residuals, 4running, 77rwf, 9, 11, 14, 22, 26, 31, 36
sales, 78schizo, 78seasadj, 27seasonaldummy, 28seasonaldummyf (seasonaldummy), 28seasonplot, 29ses, 7, 14, 30, 36set.seed, 32shampoo, 79sheep, 80ship, 80
96 INDEX
shipex, 81simulate.ets, 31sindexf, 32smooth.spline, 34splinef, 14, 33stl, 27, 32strikes, 81StructTS, 15subset.Mcomp, 90, 91summary.forecast (forecast), 13
telephone, 82texasgas, 82thetaf, 14, 35tsdisplay, 36
ukdeaths, 83usdeaths, 84uselec, 84ustreas, 85
wagesuk, 85wheat, 86wineind, 37wn, 86wnoise, 87woolyrnq, 38writing, 87