G05PMF (PDF version)
G05 Chapter Contents
G05 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

G05PMF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

G05PMF simulates from an exponential smoothing model, where the model uses either single exponential, double exponential or a Holt–Winters method.

2  Specification

SUBROUTINE G05PMF ( MODE, N, ITYPE, P, PARAM, INIT, VAR, R, STATE, E, EN, X, IFAIL)
INTEGER  MODE, N, ITYPE, P, STATE(*), EN, IFAIL
REAL (KIND=nag_wp)  PARAM(*), INIT(*), VAR, R(*), E(EN), X(N)

3  Description

G05PMF returns xt:t=1,2,,n, a realisation of a time series from an exponential smoothing model defined by one of five smoothing functions: where mt is the mean, rt is the trend and st is the seasonal component at time t with p being the seasonal order. The errors, εt are either drawn from a normal distribution with mean zero and variance σ2 or randomly sampled, with replacement, from a user-supplied vector.

4  References

Chatfield C (1980) The Analysis of Time Series Chapman and Hall

5  Parameters

1:     MODE – INTEGERInput
On entry: indicates if G05PMF is continuing from a previous call or, if not, how the initial values are computed.
MODE=0
Values for m0, r0 and s-j, for j=0,1,,p-1, are supplied in INIT.
MODE=1
G05PMF continues from a previous call using values that are supplied in R. R is not updated.
MODE=2
G05PMF continues from a previous call using values that are supplied in R. R is updated.
Constraint: MODE=0, 1 or 2.
2:     N – INTEGERInput
On entry: the number of terms of the time series being generated.
Constraint: N0.
3:     ITYPE – INTEGERInput
On entry: the smoothing function.
ITYPE=1
Single exponential.
ITYPE=2
Brown's double exponential.
ITYPE=3
Linear Holt.
ITYPE=4
Additive Holt–Winters.
ITYPE=5
Multiplicative Holt–Winters.
Constraint: ITYPE=1, 2, 3, 4 or 5.
4:     P – INTEGERInput
On entry: if ITYPE=4 or 5, the seasonal order, p, otherwise P is not referenced.
Constraint: if ITYPE=4 or 5, P>1.
5:     PARAM(*) – REAL (KIND=nag_wp) arrayInput
Note: the dimension of the array PARAM must be at least 1 if ITYPE=1 or 2, 3 if ITYPE=3 and at least 4 if ITYPE=4 or 5.
On entry: the smoothing parameters.
If ITYPE=1 or 2, PARAM1=α and any remaining elements of PARAM are not referenced.
If ITYPE=3, PARAM1=α, PARAM2=γ, PARAM3=ϕ and any remaining elements of PARAM are not referenced.
If ITYPE=4 or 5, PARAM1=α, PARAM2=γ, PARAM3=β and PARAM4=ϕ and any remaining elements of PARAM are not referenced.
Constraints:
  • if ITYPE=1, 0.0α1.0;
  • if ITYPE=2, 0.0<α1.0;
  • if ITYPE=3, 0.0α1.0 and 0.0γ1.0 and ϕ0.0;
  • if ITYPE=4 or 5, 0.0α1.0 and 0.0γ1.0 and 0.0β1.0 and ϕ0.0.
6:     INIT(*) – REAL (KIND=nag_wp) arrayInput
Note: the dimension of the array INIT must be at least 1 if ITYPE=1, 2 if ITYPE=2 or 3 and at least 2+P if ITYPE=4 or 5.
On entry: if MODE=0, the initial values for m0, r0 and s-j, for j=0,1,,p-1, used to initialize the smoothing.
If ITYPE=1, INIT1=m0 and any remaining elements of INIT are not referenced.
If ITYPE=2 or 3, INIT1=m0 and INIT2=r0 and any remaining elements of INIT are not referenced.
If ITYPE=4 or 5, INIT1=m0, INIT2=r0 and INIT3 to INIT2+p hold the values for s-j, for j=0,1,,p-1. Any remaining elements of INIT are not referenced.
7:     VAR – REAL (KIND=nag_wp)Input
On entry: the variance, σ2 of the Normal distribution used to generate the errors εi. If VAR0.0 then Normally distributed errors are not used.
8:     R(*) – REAL (KIND=nag_wp) arrayInput/Output
Note: the dimension of the array R must be at least 13 if ITYPE=1, 2 or 3 and at least 13+P if ITYPE=4 or 5.
On entry: if MODE=1 or 2, R must contain the values as returned by a previous call to G05PMF, R need not be set otherwise.
On exit: if MODE=1, R is unchanged. Otherwise, R contains the information on the current state of smoothing.
Constraint: if MODE=1 or 2, R must have been initialized by at least one call to G05PMF or G13AMF with MODE1, and R must not have been changed since that call.
9:     STATE(*) – INTEGER arrayCommunication Array
Note: the actual argument supplied must be the array STATE supplied to the initialization routines G05KFF or G05KGF.
On entry: contains information on the selected base generator and its current state.
On exit: contains updated information on the state of the generator.
10:   E(EN) – REAL (KIND=nag_wp) arrayInput
On entry: if EN>0 and VAR0.0, a vector from which the errors, εt are randomly drawn, with replacement.
If EN0, E is not referenced.
11:   EN – INTEGERInput
On entry: if EN>0, then the length of the vector E.
If both VAR0.0 and EN0 then εt=0.0, for t=1,2,,n.
12:   X(N) – REAL (KIND=nag_wp) arrayOutput
On exit: the generated time series, xt, for t=1,2,,n.
13:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
IFAIL=1
On entry, MODE0, 1 or 2.
IFAIL=2
On entry, ITYPE1, 2, 3, 4 or 5.
IFAIL=3
On entry,ITYPE=4 or 5 and P<2.
IFAIL=4
On entry, at least one of α, β or γ>0.0 or >1.0.
On entry, ITYPE=2 and α=0.0.
On entry, ϕ<0.0.
IFAIL=5
On entry,N<0.
IFAIL=8
On entry,MODE=1 or 2 and the array R has not been initialized correctly.
IFAIL=9
On entry, the array STATE has not been initialized correctly.
IFAIL=12
ITYPE=5 and model is unsuitable for multiplicative Holt–Winter.

7  Accuracy

Not applicable.

8  Further Comments

None.

9  Example

This example reads 11 observations from a time series relating to the rate of the earth's rotation about its polar axis and fits an exponential smoothing model using G13AMF.
G05PMF is then called multiple times to obtain simulated forecast confidence intervals.

9.1  Program Text

Program Text (g05pmfe.f90)

9.2  Program Data

Program Data (g05pmfe.d)

9.3  Program Results

Program Results (g05pmfe.r)

Produced by GNUPLOT 4.4 patchlevel 0 100 150 200 250 300 350 0 5 10 15 20 25 30 35 Data Time Example Program Exponential Smoothing (95% confidence intervals (CIs) are shown) observed smoothed forecast estimated CI simulated CI bootstrapped CI

G05PMF (PDF version)
G05 Chapter Contents
G05 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012