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:
– 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:
– IntegerInput
-
On entry: the number of terms of the time series being generated.
Constraint:
.
- 3:
– Nag_ExpSmoothTypeInput
-
On entry: the smoothing function.
- Single exponential.
- Brown's double exponential.
- Linear Holt.
- Additive Holt–Winters.
- Multiplicative Holt–Winters.
Constraint:
, , , or .
- 4:
– IntegerInput
-
On entry: if
or
, the seasonal order,
, otherwise
p is not referenced.
Constraint:
if or , .
- 5:
– 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:
– 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:
– doubleInput
-
On entry: the variance, of the Normal distribution used to generate the errors . If then Normally distributed errors are not used.
- 8:
– 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:
– IntegerCommunication Array
-
Note: the dimension,
, of this array is dictated by the requirements of associated functions that must have been previously called. This array MUST be the same array passed as argument
state in the previous call to
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:
– const doubleInput
-
On entry: if
and
, a vector from which the errors,
are randomly drawn, with replacement.
If
,
e is not referenced.
- 11:
– IntegerInput
-
On entry: if
, then the length of the vector
e.
If both and then
, for .
- 12:
– doubleOutput
-
On exit: the generated time series,
, for .
- 13:
– NagError *Input/Output
-
The NAG error argument (see
Section 3.6 in the Essential Introduction).
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
See
Section 3.2.1.2 in the Essential Introduction for further information.
- NE_BAD_PARAM
-
On entry, argument had an illegal value.
- NE_ENUM_INT
-
On entry, and .
Constraint:
if or , .
On entry, .
Constraint: if or , .
- NE_INT
-
On entry, .
Constraint: .
- 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.
An unexpected error has been triggered by this function. Please contact
NAG.
See
Section 3.6.6 in the Essential Introduction for further information.
- NE_INVALID_STATE
-
On entry,
state vector has been corrupted or not initialized.
- NE_NO_LICENCE
-
Your licence key may have expired or may not have been installed correctly.
See
Section 3.6.5 in the Essential Introduction for further information.
- 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.
nag_rand_exp_smooth (g05pmc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
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.