hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_univar_robust_1var_trimmed (g07dd)

Purpose

nag_univar_robust_1var_trimmed (g07dd) calculates the trimmed and Winsorized means of a sample and estimates of the variances of the two means.

Syntax

[tmean, wmean, tvar, wvar, k, sx, ifail] = g07dd(x, alpha, 'n', n)
[tmean, wmean, tvar, wvar, k, sx, ifail] = nag_univar_robust_1var_trimmed(x, alpha, 'n', n)

Description

nag_univar_robust_1var_trimmed (g07dd) calculates the αα-trimmed mean and αα-Winsorized mean for a given αα, as described below.
Let xixi, for i = 1,2,,ni=1,2,,n represent the nn sample observations sorted into ascending order. Let k = [αn]k=[αn] where [y][y] represents the integer nearest to yy; if 2k = n 2k=n  then k k  is reduced by 11.
Then the trimmed mean is defined as:
nk
xt = 1/(n2k)xi,
i = k + 1
x-t = 1 n-2k i=k+1 n-k xi ,
and the Winsorized mean is defined as:
xw = 1/n
(nk )
xi + kxk + 1 + kxnk
i = k + 1
.
x-w = 1n ( i=k+ 1 n-k xi + k x k+1 + k x n-k ) .
nag_univar_robust_1var_trimmed (g07dd) then calculates the Winsorized variance about the trimmed and Winsorized means respectively and divides by nn to obtain estimates of the variances of the above two means.
Thus we have;
Estimate of ​ var(xt) = 1/(n2)
(nk )
(xixt)2 + k(xk + 1xt)2 + k(xnkxt)2
i = k + 1
Estimate of ​ var( x-t ) = 1n2 ( i=k+1 n-k ( xi - x-t ) 2 + k ( xk+1 - x-t ) 2 + k ( xn-k - x-t ) 2 )
and
Estimate of ​ var(xw) = 1/(n2)
(nk )
(xixw)2 + k(xk + 1xw)2 + k(xnkxw)2
i = k + 1
.
Estimate of ​ var( x-w ) = 1 n2 ( i=k+ 1 n-k ( xi - x-w ) 2 + k ( xk+ 1 - x-w ) 2 + k ( xn-k - x-w ) 2 ) .

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

Parameters

Compulsory Input Parameters

1:     x(n) – double array
n, the dimension of the array, must satisfy the constraint n2n2.
The sample observations, xixi, for i = 1,2,,ni=1,2,,n.
2:     alpha – double scalar
αα, the proportion of observations to be trimmed at each end of the sorted sample.
Constraint: 0.0alpha < 0.50.0alpha<0.5.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the array x.
nn, the number of observations.
Constraint: n2n2.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     tmean – double scalar
The αα-trimmed mean, xtx-t.
2:     wmean – double scalar
The αα-Winsorized mean, xwx-w.
3:     tvar – double scalar
Contains an estimate of the variance of the trimmed mean.
4:     wvar – double scalar
Contains an estimate of the variance of the Winsorized mean.
5:     k – int64int32nag_int scalar
Contains the number of observations trimmed at each end, kk.
6:     sx(n) – double array
Contains the sample observations sorted into ascending order.
7:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,n1n1.
  ifail = 2ifail=2
On entry,alpha < 0.0alpha<0.0,
oralpha0.5alpha0.5.

Accuracy

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

Further Comments

The time taken is proportional to nn.

Example

function nag_univar_robust_1var_trimmed_example
x = [26;
     12;
     9;
     2;
     5;
     6;
     8;
     14;
     7;
     3;
     1;
     11;
     10;
     4;
     17;
     21];
alpha = 0.15;
[tmean, wmean, tvar, wvar, k, sx, ifail] = nag_univar_robust_1var_trimmed(x, alpha)
 

tmean =

    8.8333


wmean =

    9.1250


tvar =

    1.5434


wvar =

    1.5381


k =

                    2


sx =

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    14
    17
    21
    26


ifail =

                    0


function g07dd_example
x = [26;
     12;
     9;
     2;
     5;
     6;
     8;
     14;
     7;
     3;
     1;
     11;
     10;
     4;
     17;
     21];
alpha = 0.15;
[tmean, wmean, tvar, wvar, k, sx, ifail] = g07dd(x, alpha)
 

tmean =

    8.8333


wmean =

    9.1250


tvar =

    1.5434


wvar =

    1.5381


k =

                    2


sx =

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    14
    17
    21
    26


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013