NAG Library Routine Document
G07DDF calculates the trimmed and Winsorized means of a sample and estimates of the variances of the two means.
||N, K, IFAIL
||X(N), ALPHA, TMEAN, WMEAN, TVAR, WVAR, SX(N)
G07DDF calculates the -trimmed mean and -Winsorized mean for a given , as described below.
Let , for represent the sample observations sorted into ascending order. Let where represents the integer nearest to ; if then is reduced by .
Then the trimmed mean is defined as:
and the Winsorized mean is defined as:
G07DDF then calculates the Winsorized variance about the trimmed and Winsorized means respectively and divides by
to obtain estimates of the variances of the above two means.
Thus we have;
Hampel F R, Ronchetti E M, Rousseeuw P J and Stahel W A (1986) Robust Statistics. The Approach Based on Influence Functions Wiley
Huber P J (1981) Robust Statistics Wiley
- 1: N – INTEGERInput
On entry: , the number of observations.
- 2: X(N) – REAL (KIND=nag_wp) arrayInput
On entry: the sample observations,
, for .
- 3: ALPHA – REAL (KIND=nag_wp)Input
On entry: , the proportion of observations to be trimmed at each end of the sorted sample.
- 4: TMEAN – REAL (KIND=nag_wp)Output
On exit: the -trimmed mean, .
- 5: WMEAN – REAL (KIND=nag_wp)Output
On exit: the -Winsorized mean, .
- 6: TVAR – REAL (KIND=nag_wp)Output
On exit: contains an estimate of the variance of the trimmed mean.
- 7: WVAR – REAL (KIND=nag_wp)Output
On exit: contains an estimate of the variance of the Winsorized mean.
- 8: K – INTEGEROutput
On exit: contains the number of observations trimmed at each end, .
- 9: SX(N) – REAL (KIND=nag_wp) arrayOutput
On exit: contains the sample observations sorted into ascending order.
- 10: IFAIL – INTEGERInput/Output
must be set to
. 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
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
. When the value is used it is essential to test the value of IFAIL 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
, explanatory error messages are output on the current error message unit (as defined by X04AAF
Errors or warnings detected by the routine:
The results should be accurate to within a small multiple of machine precision.
The time taken is proportional to .
The following program finds the -trimmed mean and -Winsorized mean for a sample of observations where . The estimates of the variances of the above two means are also calculated.
9.1 Program Text
Program Text (g07ddfe.f90)
9.2 Program Data
Program Data (g07ddfe.d)
9.3 Program Results
Program Results (g07ddfe.r)