0% found this document useful (0 votes)
14 views4 pages

Time Series Analysis Methos

The document discusses various time series forecasting methods, particularly focusing on exponential smoothing techniques, including the Holt-Winters method. It explains the mathematical foundations of these methods, their applications in different fields, and provides examples using R programming. Additionally, it touches on the Rmpi interface for parallel statistical computing, highlighting the advantages of MPI in performance and portability.

Uploaded by

thuyttt6916
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

Time Series Analysis Methos

The document discusses various time series forecasting methods, particularly focusing on exponential smoothing techniques, including the Holt-Winters method. It explains the mathematical foundations of these methods, their applications in different fields, and provides examples using R programming. Additionally, it touches on the Rmpi interface for parallel statistical computing, highlighting the advantages of MPI in performance and portability.

Uploaded by

thuyttt6916
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Vol.

2/2, June 2002 7

it is now possible to get the R garbage collector to do A. C. Harvey. Forecasting, Structural Time Series Models and
this via a finalizer. the Kalman Filter. Cambridge University Press, 1989. 5

A. Pole, M. West, and J. Harrison. Applied Bayesian Fore-


casting and Time Series Analysis. Chapman & Hall, 1994.
Bibliography 5

Peter J. Brockwell and Richard A. Davis. Introduction to W. N. Venables and B. D. Ripley. Modern Applied Statistics
Time Series and Forecasting. Springer-Verlag, New York, with S-PLUS. Springer-Verlag, New York, third edition,
1996. 5, 6 1999. 2

P. J. Diggle. Time Series: A Biostatistical Introduction. Oxford W. N. Venables and B. D. Ripley. Modern Applied Statistics
University Press, Oxford, 1990. 4 with S. Springer-Verlag, New York, fourth edition, 2002.
2, 4
J. Durbin and S. J. Koopman, editors. Time Series Analysis
by State Space Methods. Oxford University Press, Oxford, Mike West and Jeff Harrison. Bayesian Forecasting and Dy-
2001. ISBN 0-19-852354-8. 4, 5 namic Models. Springer-Verlag, New York, second edi-
tion, 1997. ISBN 0-387-94725-6. 5
G. Gardner, A. C. Harvey, and G. D. A. Phillips. Algorithm
as154. an algorithm for exact maximum likelihood es-
timation of autoregressive-moving average models by Brian D. Ripley
means of kalman filtering. Applied Statistics, 29:311–322. University of Oxford, UK
4 [email protected]

Naive Time Series Forecasting Methods


The Holt-Winters Method in package ts give some examples of their application.

by David Meyer
Exponential smoothing
Exponential smoothing methods forecast time series
by discounted past observations. They have be- Let Yt denote a univariate time series. Exponential
come very popular because of their (relative) sim- smoothing assumes that the forecast Ŷ for period
plicity compared to their good overall performance. t + h based on period t is given by a variable level
Common applications range from business tasks â at period t
(e.g., forecasting of sales or stock fluctuations) to Ŷt+h = ât (1)
environmental studies (e.g., measurements of atmo-
which is recursively estimated by a weighted aver-
spheric components or rainfall data)—with typically
age of the observed and the predicted value for Yt :
no more a priori knowledge than the possible exis-
tence of trend of seasonal patterns. Such methods ât = α Yt + (1 − α )Ŷt
are sometimes also called naive because no covariates
= α Yt + (1 − α ) ât−1
are used in the models, i.e., the data are assumed to
be self-explaining. Their success is rooted in the fact
0 < α < 1 called the smoothing parameter; the
that they belong to a class of local models which au-
smaller it is chosen, the less sensitive Ŷ becomes for
tomatically adapt their parameters to the data dur-
changes (i.e., the smoother the forecast time series
ing the estimation procedure and therefore implic-
will be). The initial value â1 is usually chosen as Y1 .
itly account for (slow) structural changes in the train-
An equivalent formulation for ât is the so called
ing data. Moreover, because the influence of new
error-correction form:
data is controlled by hyperparameters, the effect is
a smoothing of the original time series. ât = ât−1 + α (Yt − ât−1 )
Among the simplest methods is the ordinary ex- = ât−1 + α (Yt − Ŷt ) (2)
ponential smoothing, which assumes no trend and = ât−1 + α et
no seasonality. Holt’s linear trend method (see Holt,
1957) and Winters extensions (see Winters, 1960) add showing that ât can be estimated by ât−1 plus an er-
a trend and a seasonal component (the latter either ror e made in period t. (We will come back to this
additive or multiplicative). Their methods are still later on.)
surprisingly popular, although many extensions and Exponential smoothing can be seen as a special
more general frameworks do exist. We describe case of the Holt-Winters method with no trend and
briefly the methods implemented in package ts and no seasonal component. As an example, we use the

R News ISSN 1609-3631


Vol. 2/2, June 2002 8

Nile data for which an intercept-only model seems Holt’s linear trend method
appropriate1 . We will try to predict the values from
1937 on, choosing α = 0.2: An obvious extension is to include an additional
library(ts) trend component, say b̂t . The forecast equation be-
data(Nile) comes:
past <- window(Nile, end = 1936)
Ŷt+h = ât + h · b̂t
future <- window(Nile, start = 1937)
alpha <- 0.2
with updating formulas expressing similar ideas to
To obtain a level-only model, we set the other hyper- those for exponential smoothing. There is an addi-
parameters β and γ (see the next sections) to 0: tional formula for the trend component:
model <- HoltWinters(past, alpha = alpha,
beta = 0, gamma = 0) ât = αYt + (1 − α )( ât−1 + b̂t−1 )
The object model contains an object of type b̂t = β ( ât − ât−1 ) + (1 − β) b̂t−1
"HoltWinters". The fitted values (obtained by
fitted(model)) should of course be identical2 to The use is a local fit of a straight line with the coef-
those given by filter: ficients adjusted for new values. We now have one
more parameter to choose: β. A straightforward ap-
filter(alpha * past, filter = 1 - alpha,
method = "recursive", init = past[1])
proach to find the optimal values for both α and β
is to look for the OLS estimates, i.e., the parame-
We predict 43 periods ahead (until the end of the se- ter combination minimizing the sum of squared er-
ries): rors of the one-step-ahead predictions. That is what
pred <- predict(model, n.ahead = 43) HoltWinters does for all the unspecified parameters,
illustrated below for the Australian residents data:
The plot method for Holt-Winters objects shows the
observed and fitted values, and optionally adds the data(austres)
predicted values (see figure 1): past <- window(austres, start = c(1985, 1),
plot(model, predicted.values = pred) end = c(1989, 4))
lines(future) future <- window(austres, start = c(1990, 1))
(model <- HoltWinters(past, gamma = 0))
Holt−Winters filtering
Holt-Winters exponential smoothing with trend
1400

and without seasonal component.

Call:
1200

HoltWinters(x = past, gamma = 0)

Smoothing parameters:
1000
Observed / Fitted

alpha: 0.931416
beta : 0.494141
gamma: 0
800

Coefficients:
[,1]
a 16956.68845
600

b 63.58486

The start values for ât and b̂t are Y [2] and Y [2] − Y [1],
1880 1900 1920 1940 1960 1980
respectively; the parameters are estimated via optim
Time
using method = "L-BFGS-B", restricting the parame-
ters to the unit cube.
Figure 1: Exponential smoothing for the Nile data up Another feature is the optional computation of
to 1937, and the predictions in 1937 of the rest of the confidence intervals for the predicted values, which
series. The original series is in shown in gray. by default are plotted along with them (see figure 2):

The coefficients (here only the level) are listed in the pred <- predict(model, n.ahead = 14,
output produced by print() or can be extracted with prediction.interval = TRUE)
coef(). plot(model, pred); lines(future)
1 At least piecewise: note that one might expect a structural break in 1899 due to the construction of the first Ashwan dam
2 Currently the initial value is only observation 2 as it is for the trend model (for which this is sensible). This will be changed in R 1.5.1.

R News ISSN 1609-3631


Vol. 2/2, June 2002 9

For automatic parameter selection, we need at least


Holt−Winters filtering
three complete cycles to estimate an initial seasonal
component, done via a classical seasonal decompo-
18000

sition using moving averages performed by the new


function decompose(). The intercept and trend are
estimated by a simple regression on the extracted
17500

trend component.
As an example, we apply the multiplicative ver-
Observed / Fitted

sion to the UK gas consumption data for 1960–80 and


17000

predict the next six years.


16500

data(UKgas)
past <- window(UKgas, end = c(1980, 4))
future <- window(UKgas, start = c(1981, 1))
16000

model <- HoltWinters(past, seasonal = "mult")


pred <- predict(model, n.ahead = 24)

1986 1988 1990 1992


For clarity, we plot the original time series and the
Time
predicted values separately (see figure 3):

par(mfrow = c(2,1))
Figure 2: Holt’s linear trend method applied to data plot(UKgas, main = "Original Time Series")
on Autralian residents, with 95% confidence limits in plot(model, pred)
dashed blue lines. Original data are plotted in gray,
fitted and predicted values in red. Original Time Series
1000

Winters’ seasonal method


UKgas

600

Winters extended the method to include a seasonal


200

component. There are additive and multiplicative


versions. In the following, we suppose seasonal 1960 1965 1970 1975 1980 1985
trend components ŝt and a period p (e.g., 4 for quar-
Time
terly data).
Holt−Winters filtering
Additive version
1000
Observed / Fitted

The additive model assumes the decomposition:


600

Ŷt+h = ât + h · b̂t + ŝt


200

with an additional updating formula for the seasonal


1960 1965 1970 1975 1980 1985
component:
Time

ât = α (Yt − ŝt− p ) + (1 − α )( ât−1 + b̂t−1 )


b̂t = β ( ât − ât−1 ) + (1 − β) b̂t−1 Figure 3: Winter’s method applied to quarterly UK
ŝt = γ (Yt − ât ) + (1 − γ ) ŝt− p gas consumption data. The upper figure is the actual
data, the lower the data (gray) and fited values (red)
up to 1980Q4, the predictions (red) thereafter.
Multiplicative version
This version assumes a model with time-increasing
seasonal component (i.e., the amplitude becomes Conclusion
larger with increasing t). The prediction formula be-
comes: We have seen that the Holt-Winters method con-
Ŷt+h = ( ât + h · b̂t ) ŝt sists in a simple yet effective forecasting procedure,
based on exponential moving averages, covering
and the updating formulas change accordingly: both trend and seasonal models. Many extensions
ât = α (Yt − ŝt− p ) + (1 − α )( ât−1 + b̂t−1 ) exist however (see, e.g., Hyndman et al., 2001), and
the various formulations can also be seen as special
b̂t = β ( ât − ât−1 ) + (1 − β) b̂t−1 cases of a wider class of models. For example, all but
ŝt = γ (Yt / ât ) + (1 − γ ) ŝt− p the multiplicative Holt-Winters can be identified as

R News ISSN 1609-3631


Vol. 2/2, June 2002 10

(restricted) SARIMA models. To motivate this, con- Bibliography


sider equation 2—the error-correction form of expo-
nential smoothing. By plugging it into the forecast- Holt, C. (1957). Forecasting seasonals and trends by ex-
ing equation 1, we almost directly obtain: ponentially weighted moving averages. ONR Research
Memorandum, Carnegie Institute 52. 7

(1 − L)Ŷt = α e t−1 Hyndman, R., Koehler, A., Snyder, R., & Grose, S. (2001).
A state space framework for automatic forecasting using
= (1 − θL)et exponential smoothing methods. Journal of Forecasting.
To appear. 9
(θ = 1 − α), which is (in terms of estimates) the stan- Winters, P. (1960). Forecasting sales by exponentially
dard form of an ARIMA(0,1,1)-process. Finally, we weighted moving averages. Management Science, 6, 324–
note that we actually face state-space models: given 342. 7
process Yt , we try to estimate the underlying pro-
cesses at , bt and st which cannot be observed directly.
But this is the story of structural time series and the David Meyer
function structTS, told in an another article by Brian Technische Universität Wien, Austria
D. Ripley . . . [email protected]

Rmpi: Parallel Statistical Computing in R


by Hao Yu packing data into a system designated buffer on the
sender side and unpacking from a system buffer on
Rmpi is an R interface (wrapper) to the Message- the receiver side. This reduces the user’s responsibil-
Passing Interface (MPI). MPI is a standard appli- ity for managing the buffer; on the other hand, this
cation interface (API) governed by the MPI forum may create problems of running out of buffer space if
(http://www.mpi-forum.org) for running parallel large amounts of data are transferred. PVM can also
applications. Applicable computing environments lead to performance draining copies. MPI, by con-
range from dedicated Beowulf PC clusters to paral- trast, requires no buffering of data within the system.
lel supercomputers such as IBM’s SP2. Performance This allows MPI to be implemented on the widest
and portability are the two main strengths of MPI. range of platforms, with great efficiency. Perhaps
In this article, we demonstrate how the MPI API is Luke Tierney’s package snow (Simple Network of
implemented in Rmpi. In particular, we show how Workstations, http://www.stat.umn.edu/~luke/R/
interactive R slaves are spawned and how we use cluster) will ultimately provide a unified interface
them to do sophisticated MPI parallel programming to both Rmpi and rpvm so users can freely choose
beyond the “embarrassingly parallel”. either one to implement parallel computing.

There are 128 routines in the MPI-1 standard and


Introduction 287 functions in the combined MPI (MPI-1 and MPI-
2) standard. MPI is rich in functionality; it is also ca-
Put simply, parallel statistical computing means di-
pable of handling the diversity and complexity of to-
viding a job into many small parts which will be
day’s high performance computers. Likely the envi-
executed simultaneously over a cluster of comput-
ronment with highest potential for MPI use is the Be-
ers linked together in a network (LAN or WAN).
owulf cluster, a high-performance massively paral-
Communications among the components is a crucial
lel computer built primarily out of commodity hard-
aspect of parallel computing. The message-passing
ware components.
model is highly suitable for such a task. There are
two primary open-source message-passing models
available: MPI and PVM (Parallel Virtual Machine, One of the goals of Rmpi is to provide an exten-
Geist et al., 1994). For PVM’s implementation rpvm sive MPI API in the R environment. Using R as an
in R, see Li and Rossini, 2001. interface, the user can either spawn C(++) or Fortran
Whether to use MPI or PVM largely depends on programs as children or join other MPI programs.
the underlying hardware structure and one’s per- Another goal is to provide an interactive R master
sonal preference. Both models provide a parallel pro- and slave environment so MPI programming can be
gramming interface. The main difference is in how done completely in R. This was achieved by imple-
buffers are managed or used for sending and receiv- menting a set of MPI API extensions specifically de-
ing data. Typically, in PVM, users are responsible for signed for the R or R slave environments.

R News ISSN 1609-3631

You might also like