g13au 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.
Syntax
C# |
---|
public static void g13au( int n, double[] z, int m, int ngrps, string rs, double[] y, double[] mean, out int ifail ) |
Visual Basic |
---|
Public Shared Sub g13au ( _ n As Integer, _ z As Double(), _ m As Integer, _ ngrps As Integer, _ rs As String, _ y As Double(), _ mean As Double(), _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void g13au( int n, array<double>^ z, int m, int ngrps, String^ rs, array<double>^ y, array<double>^ mean, [OutAttribute] int% ifail ) |
F# |
---|
static member g13au : n : int * z : float[] * m : int * ngrps : int * rs : string * y : float[] * mean : float[] * ifail : int byref -> unit |
Parameters
- n
- Type: System..::..Int32On entry: , the number of observations in the time series.Constraint: .
- z
- Type: array<System..::..Double>[]()[][]An array of size [n]On entry: must contain the th observation , for .
- m
- Type: System..::..Int32On entry: , the group size.Constraint: .
- ngrps
- Type: System..::..Int32On entry: , the number of groups.Constraint: .
- rs
- Type: System..::..StringOn entry: indicates whether ranges or standard deviations are to be calculated.
- Ranges are calculated.
- Standard deviations are calculated.
Constraint: or .
- y
- Type: array<System..::..Double>[]()[][]An array of size [ngrps]On exit: contains the range or standard deviation, as determined by rs, of the th group of observations, for .
- mean
- Type: array<System..::..Double>[]()[][]An array of size [ngrps]On exit: contains the mean of the th group of observations, for .
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
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.
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
Error Indicators and Warnings
Errors or warnings detected by the method:
On entry, , or , or integer part of .
On entry, rs is not equal to "R" or "S".
Accuracy
The computations are believed to be stable.
Parallelism and Performance
None.
Further Comments
The time taken by g13au is approximately proportional to .
Example
The following program produces the statistics for a range-mean plot for a series of observations divided into groups of .
Example program (C#): g13aue.cs