NAG Library Function Document
nag_robust_trimmed_1var (g07ddc) calculates the trimmed and Winsorized means of a sample and estimates of the variances of the two means.
||nag_robust_trimmed_1var (Integer n,
const double x,
nag_robust_trimmed_1var (g07ddc) 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 1.
Then the trimmed mean is defined as:
and the Winsorized mean is defined as:
nag_robust_trimmed_1var (g07ddc) 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
n – IntegerInput
On entry: the number of observations, .
x[n] – const doubleInput
On entry: the sample observations, , for .
alpha – doubleInput
On entry: the proportion of observations to be trimmed at each end of the sorted sample, .
tmean – double *Output
On exit: the -trimmed mean, .
wmean – double *Output
On exit: the -Winsorized mean, .
tvar – double *Output
On exit: contains an estimate of the variance of the trimmed mean.
wvar – double *Output
On exit: contains an estimate of the variance of the Winsorized mean.
k – Integer *Output
On exit: contains the number of observations trimmed at each end, .
sx[n] – doubleOutput
On exit: contains the sample observations sorted into ascending order.
fail – NagError *Input/Output
The NAG error argument (see Section 3.6
in the Essential Introduction).
6 Error Indicators and Warnings
On entry, .
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG
On entry, alpha
must not be greater than or equal to 0.5:
On entry, alpha
must not be less than 0.0:
The results should be accurate to within a small multiple of machine precision.
8 Parallelism and Performance
The time taken by nag_robust_trimmed_1var (g07ddc) is proportional to .
The following program finds the -trimmed mean and -Winsorized mean for a sample of 16 observations where . The estimates of the variances of the above two means are also calculated.
10.1 Program Text
Program Text (g07ddce.c)
10.2 Program Data
Program Data (g07ddce.d)
10.3 Program Results
Program Results (g07ddce.r)