NAG Library Routine Document
g13auf (uni_means)
1
Purpose
g13auf calculates the range (or standard deviation) and the mean for groups of successive time series values. It is intended for use in the construction of range-mean plots.
2
Specification
Fortran Interface
Integer, Intent (In) | :: | n, m, ngrps | Integer, Intent (Inout) | :: | ifail | Real (Kind=nag_wp), Intent (In) | :: | z(n) | Real (Kind=nag_wp), Intent (Out) | :: | y(ngrps), mean(ngrps) | Character (1), Intent (In) | :: | rs |
|
C Header Interface
#include <nagmk26.h>
void |
g13auf_ (const Integer *n, const double z[], const Integer *m, const Integer *ngrps, const char *rs, double y[], double mean[], Integer *ifail, const Charlen length_rs) |
|
3
Description
Let denote successive observations in a time series. The series may be divided into groups of successive values and for each group the range or standard deviation (depending on a user-supplied option) and the mean are calculated. If is not a multiple of then groups of equal size are found starting from the end of the series of observations provided, and any remaining observations at the start of the series are ignored. The number of groups used, , is the integer part of . If you wish to ensure that no observations are ignored then the number of observations, , should be chosen so that is divisible by .
The mean,
, the range,
, and the standard deviation,
, for the
th group are defined as
and
where
, the number of observations ignored.
For seasonal data it is recommended that should be equal to the seasonal period. For non-seasonal data the recommended group size is .
A plot of range against mean or of standard deviation against mean is useful for finding a transformation of the series which makes the variance constant. If the plot appears random or the range (or standard deviation) seems to be constant irrespective of the mean level then this suggests that no transformation of the time series is called for. On the other hand an approximate linear relationship between range (or standard deviation) and mean would indicate that a log transformation is appropriate. Further details may be found in either
Jenkins (1979) or
McLeod (1982).
You have the choice of whether to use the range or the standard deviation as a measure of variability. If the group size is small they are both equally good but if the group size is fairly large (e.g., for monthly data) then the range may not be as good an estimate of variability as the standard deviation.
4
References
Jenkins G M (1979) Practical Experiences with Modelling and Forecasting Time Series GJP Publications, Lancaster
McLeod G (1982) Box–Jenkins in Practice. 1: Univariate Stochastic and Single Output Transfer Function/Noise Analysis GJP Publications, Lancaster
5
Arguments
- 1: – IntegerInput
-
On entry: , the number of observations in the time series.
Constraint:
.
- 2: – Real (Kind=nag_wp) arrayInput
-
On entry: must contain the th observation , for .
- 3: – IntegerInput
-
On entry: , the group size.
Constraint:
.
- 4: – IntegerInput
-
On entry: , the number of groups.
Constraint:
.
- 5: – Character(1)Input
-
On entry: indicates whether ranges or standard deviations are to be calculated.
- Ranges are calculated.
- Standard deviations are calculated.
Constraint:
or .
- 6: – Real (Kind=nag_wp) arrayOutput
-
On exit:
contains the range or standard deviation, as determined by
rs, of the
th group of observations, for
.
- 7: – Real (Kind=nag_wp) arrayOutput
-
On exit: contains the mean of the th group of observations, for .
- 8: – IntegerInput/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this argument, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
On entry, , and .
Constraint: .
On entry, and .
Constraint: .
-
On entry, .
Constraint: or .
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7
Accuracy
The computations are believed to be stable.
8
Parallelism and Performance
g13auf is not threaded in any implementation.
The time taken by g13auf is approximately proportional to .
10
Example
The following program produces the statistics for a range-mean plot for a series of observations divided into groups of .
10.1
Program Text
Program Text (g13aufe.f90)
10.2
Program Data
Program Data (g13aufe.d)
10.3
Program Results
Program Results (g13aufe.r)