NAG CL Interface
g07ddc (robust_​1var_​trimmed)

Settings help

CL Name Style:


1 Purpose

g07ddc calculates the trimmed and Winsorized means of a sample and estimates of the variances of the two means.

2 Specification

#include <nag.h>
void  g07ddc (Integer n, const double x[], double alpha, double *tmean, double *wmean, double *tvar, double *wvar, Integer *k, double sx[], NagError *fail)
The function may be called by the names: g07ddc, nag_univar_robust_1var_trimmed or nag_robust_trimmed_1var.

3 Description

g07ddc calculates the α -trimmed mean and α -Winsorized mean for a given α , as described below.
Let x i , for i=1,2,,n, represent the n sample observations sorted into ascending order. Let k = [αn] where [y] represents the integer nearest to y; if 2k=n then k is reduced by 1.
Then the trimmed mean is defined as:
x¯t = 1 n-2k i=k+1 n-k xi ,  
and the Winsorized mean is defined as:
x¯w = 1n i=k+1 n-k xi + ( kx k+1 ) + ( kx n-k ) .  
g07ddc then calculates the Winsorized variance about the trimmed and Winsorized means respectively and divides by n to obtain estimates of the variances of the above two means.
Thus we have
Estimate of ​ var( x ¯ t ) = 1 n 2 i = k + 1 n-k ( x i - x ¯ t ) 2 + k ( x k+1 - x ¯ t ) 2 + k ( x n-k - x ¯ t ) 2  
and
Estimate of ​ var( x ¯ w ) = 1 n 2 i = k + 1 n-k ( x i - x ¯ w ) 2 + k ( x k+1 - x ¯ w ) 2 + k ( x n-k - x ¯ w ) 2 .  

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: n Integer Input
On entry: the number of observations, n .
Constraint: n2 .
2: x[n] const double Input
On entry: the sample observations, x i , for i=1,2,,n.
3: alpha double Input
On entry: the proportion of observations to be trimmed at each end of the sorted sample, α .
Constraint: 0.0 alpha < 0.5 .
4: tmean double * Output
On exit: the α -trimmed mean, x ¯ t .
5: wmean double * Output
On exit: the α -Winsorized mean, x ¯ w .
6: tvar double * Output
On exit: contains an estimate of the variance of the trimmed mean.
7: wvar double * Output
On exit: contains an estimate of the variance of the Winsorized mean.
8: k Integer * Output
On exit: contains the number of observations trimmed at each end, k .
9: sx[n] double Output
On exit: contains the sample observations sorted into ascending order.
10: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_INT_ARG_LT
On entry, n=value.
Constraint: n2.
NE_INTERNAL_ERROR
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 for assistance.
NE_REAL_ARG_GE
On entry, alpha must not be greater than or equal to 0.5: alpha=value .
NE_REAL_ARG_LT
On entry, alpha must not be less than 0.0: alpha=value .

7 Accuracy

The results should be accurate to within a small multiple of machine precision.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
g07ddc is not threaded in any implementation.

9 Further Comments

The time taken by g07ddc is proportional to n .

10 Example

The following program finds the α -trimmed mean and α -Winsorized mean for a sample of 16 observations where α=0.15 . 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)