NAG Library Routine Document
G07DDF
1 Purpose
G07DDF calculates the trimmed and Winsorized means of a sample and estimates of the variances of the two means.
2 Specification
INTEGER |
N, K, IFAIL |
REAL (KIND=nag_wp) |
X(N), ALPHA, TMEAN, WMEAN, TVAR, WVAR, SX(N) |
|
3 Description
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.
4 References
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
5 Parameters
- 1: – INTEGERInput
-
On entry: , the number of observations.
Constraint:
.
- 2: – REAL (KIND=nag_wp) arrayInput
-
On entry: the sample observations,
, for .
- 3: – REAL (KIND=nag_wp)Input
-
On entry: , the proportion of observations to be trimmed at each end of the sorted sample.
Constraint:
.
- 4: – REAL (KIND=nag_wp)Output
-
On exit: the -trimmed mean, .
- 5: – REAL (KIND=nag_wp)Output
-
On exit: the -Winsorized mean, .
- 6: – REAL (KIND=nag_wp)Output
-
On exit: contains an estimate of the variance of the trimmed mean.
- 7: – REAL (KIND=nag_wp)Output
-
On exit: contains an estimate of the variance of the Winsorized mean.
- 8: – INTEGEROutput
-
On exit: contains the number of observations trimmed at each end, .
- 9: – REAL (KIND=nag_wp) arrayOutput
-
On exit: contains the sample observations sorted into ascending order.
- 10: – INTEGERInput/Output
-
On entry:
IFAIL 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.
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, | , |
or | . |
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.8 in the Essential Introduction for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
Dynamic memory allocation failed.
See
Section 3.6 in the Essential Introduction for further information.
7 Accuracy
The results should be accurate to within a small multiple of machine precision.
8 Parallelism and Performance
G07DDF 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 routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
The time taken is proportional to .
10 Example
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.
10.1 Program Text
Program Text (g07ddfe.f90)
10.2 Program Data
Program Data (g07ddfe.d)
10.3 Program Results
Program Results (g07ddfe.r)