NAG FL Interface
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 <nag.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) |
|
C++ Header Interface
#include <nag.h> extern "C" {
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) |
}
|
The routine may be called by the names g07ddf or nagf_univar_robust_1var_trimmed.
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:
– Integer
Input
-
On entry: , the number of observations.
Constraint:
.
-
2:
– Real (Kind=nag_wp) array
Input
-
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:
– Integer
Output
-
On exit: contains the number of observations trimmed at each end, .
-
9:
– Real (Kind=nag_wp) array
Output
-
On exit: contains the sample observations sorted into ascending order.
-
10:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
or
to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value
or
is recommended. If message printing is undesirable, then the value
is recommended. Otherwise, the value
is recommended.
When the value or 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, .
Constraint: .
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface 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
10.2
Program Data
10.3
Program Results