NAG Library Routine Document
g07ddf
(robust_1var_trimmed)
1
Purpose
g07ddf calculates the trimmed and Winsorized means of a sample and estimates of the variances of the two means.
2
Specification
Fortran Interface
Integer, Intent (In) | :: |
n | Integer, Intent (Inout) | :: |
ifail | Integer, Intent (Out) | :: |
k | Real (Kind=nag_wp), Intent (In) | :: |
x(n),
alpha | Real (Kind=nag_wp), Intent (Out) | :: |
tmean,
wmean,
tvar,
wvar,
sx(n) |
|
C Header Interface
#include nagmk26.h
void |
g07ddf_ (
const Integer *n,
const double x[],
const double *alpha,
double *tmean,
double *wmean,
double *tvar,
double *wvar,
Integer *k,
double sx[],
Integer *ifail) |
|
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
Arguments
- 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 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, | , |
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 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)