nag_rand_exp_smooth (g05pmc) simulates from an exponential smoothing model, where the model uses either single exponential, double exponential or a Holt–Winters method.
nag_rand_exp_smooth (g05pmc) returns
, a realization of a time series from an exponential smoothing model defined by one of five smoothing functions:
- Single Exponential Smoothing
- Brown Double Exponential Smoothing
- Linear Holt Exponential Smoothing
- Additive Holt–Winters Smoothing
- Multiplicative Holt–Winters Smoothing
where
is the mean,
is the trend and
is the seasonal component at time
with
being the seasonal order. The errors,
are either drawn from a normal distribution with mean zero and variance
or randomly sampled, with replacement, from a user-supplied vector.
- 1:
mode – Nag_InitialValuesInput
-
On entry: indicates if nag_rand_exp_smooth (g05pmc) is continuing from a previous call or, if not, how the initial values are computed.
- Values for , and , for , are supplied in init.
- nag_rand_exp_smooth (g05pmc) continues from a previous call using values that are supplied in r. r is not updated.
- nag_rand_exp_smooth (g05pmc) continues from a previous call using values that are supplied in r. r is updated.
Constraint:
, or .
- 2:
n – IntegerInput
-
On entry: the number of terms of the time series being generated.
Constraint:
.
- 3:
itype – Nag_ExpSmoothTypeInput
-
On entry: the smoothing function.
- Single exponential.
- Brown's double exponential.
- Linear Holt.
- Additive Holt–Winters.
- Multiplicative Holt–Winters.
Constraint:
, , , or .
- 4:
p – IntegerInput
-
On entry: if
or
, the seasonal order,
, otherwise
p is not referenced.
Constraint:
if or , .
- 5:
param[] – const doubleInput
-
Note: the dimension,
dim, of the array
param
must be at least
- when or ;
- when ;
- when or .
On entry: the smoothing parameters.
If
or
,
and any remaining elements of
param are not referenced.
If
,
,
,
and any remaining elements of
param are not referenced.
If
or
,
,
,
and
and any remaining elements of
param are not referenced.
Constraints:
- if , ;
- if , ;
- if , and and ;
- if or , and and and .
- 6:
init[] – const doubleInput
-
Note: the dimension,
dim, of the array
init
must be at least
- when ;
- when or ;
- when or .
On entry: if
, the initial values for
,
and
, for
, used to initialize the smoothing.
If
,
and any remaining elements of
init are not referenced.
If
or
,
and
and any remaining elements of
init are not referenced.
If
or
,
,
and
to
hold the values for
, for
. Any remaining elements of
init are not referenced.
- 7:
var – doubleInput
-
On entry: the variance, of the Normal distribution used to generate the errors . If then Normally distributed errors are not used.
- 8:
r[] – doubleInput/Output
-
Note: the dimension,
dim, of the array
r
must be at least
- when , or ;
- when or .
On entry: if
or
,
r must contain the values as returned by a previous call to nag_rand_exp_smooth (g05pmc),
r need not be set otherwise.
On exit: if
,
r is unchanged. Otherwise,
r contains the information on the current state of smoothing.
Constraint:
if
or
,
r must have been initialized by at least one call to nag_rand_exp_smooth (g05pmc) or
nag_tsa_exp_smooth (g13amc) with
, and
r must not have been changed since that call.
- 9:
state[] – IntegerCommunication Array
-
Note: the actual argument supplied must be the array
state supplied to the initialization functions
nag_rand_init_repeatable (g05kfc) or
nag_rand_init_nonrepeatable (g05kgc).
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] – const doubleInput
-
On entry: if
and
, a vector from which the errors,
are randomly drawn, with replacement.
If
,
e is not referenced.
- 11:
en – IntegerInput
-
On entry: if
, then the length of the vector
e.
If both and then , for .
- 12:
x[n] – doubleOutput
-
On exit: the generated time series, , for .
- 13:
fail – NagError *Input/Output
-
The NAG error argument (see
Section 3.6 in the Essential Introduction).
- NE_ALLOC_FAIL
Dynamic memory allocation failed.
- NE_BAD_PARAM
On entry, argument had an illegal value.
- NE_ENUM_INT
On entry, and .
Constraint:
if or , .
- NE_INT
On entry, .
Constraint: .
- NE_INT_2
On entry, .
Constraint: if or , .
- NE_INT_ARRAY
On entry, some of the elements of the array
r have been corrupted or have not been initialized.
- NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact
NAG for assistance.
- NE_INVALID_STATE
On entry,
state vector has been corrupted or not initialized.
- NE_REAL_ARRAY
Model unsuitable for multiplicative Holt–Winter, try a different set of
parameters.
On entry, .
Constraint: .
On entry, .
Constraint: if , .
On entry, .
Constraint: .
Not applicable.
None.
This example reads
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
nag_tsa_exp_smooth (g13amc).
nag_rand_exp_smooth (g05pmc) is then called multiple times to obtain simulated forecast confidence intervals.