nag_robust_trimmed_1var (g07ddc) (PDF version)
g07 Chapter Contents
g07 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_robust_trimmed_1var (g07ddc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

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

2  Specification

#include <nag.h>
#include <nagg07.h>
void  nag_robust_trimmed_1var (Integer n, const double x[], double alpha, double *tmean, double *wmean, double *tvar, double *wvar, Integer *k, double sx[], NagError *fail)

3  Description

nag_robust_trimmed_1var (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 .
nag_robust_trimmed_1var (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:     nIntegerInput
On entry: the number of observations, n .
Constraint: n2 .
2:     x[n]const doubleInput
On entry: the sample observations, x i , for i=1,2,,n.
3:     alphadoubleInput
On entry: the proportion of observations to be trimmed at each end of the sorted sample, α .
Constraint: 0.0 alpha < 0.5 .
4:     tmeandouble *Output
On exit: the α -trimmed mean, x - t .
5:     wmeandouble *Output
On exit: the α -Winsorized mean, x - w .
6:     tvardouble *Output
On exit: contains an estimate of the variance of the trimmed mean.
7:     wvardouble *Output
On exit: contains an estimate of the variance of the Winsorized mean.
8:     kInteger *Output
On exit: contains the number of observations trimmed at each end, k .
9:     sx[n]doubleOutput
On exit: contains the sample observations sorted into ascending order.
10:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

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

Not applicable.

9  Further Comments

The time taken by nag_robust_trimmed_1var (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)


nag_robust_trimmed_1var (g07ddc) (PDF version)
g07 Chapter Contents
g07 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2014