PDF version (NAG web site
, 64-bit version, 64-bit version)
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
Description
nag_univar_robust_1var_trimmed (g07dd) 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:
nag_univar_robust_1var_trimmed (g07dd) 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.
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:
– double array
-
The sample observations,
, for .
- 2:
– double scalar
-
, the proportion of observations to be trimmed at each end of the sorted sample.
Constraint:
.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
x.
, the number of observations.
Constraint:
.
Output Parameters
- 1:
– double scalar
-
The -trimmed mean, .
- 2:
– double scalar
-
The -Winsorized mean, .
- 3:
– double scalar
-
Contains an estimate of the variance of the trimmed mean.
- 4:
– double scalar
-
Contains an estimate of the variance of the Winsorized mean.
- 5:
– int64int32nag_int scalar
-
Contains the number of observations trimmed at each end, .
- 6:
– double array
-
Contains the sample observations sorted into ascending order.
- 7:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
-
-
On entry, | , |
or | . |
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
The results should be accurate to within a small multiple of
machine precision.
Further Comments
The time taken is proportional to .
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.
Open in the MATLAB editor:
g07dd_example
function g07dd_example
fprintf('g07dd example results\n\n');
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);
propn = 100*(1-2*double(k)/numel(x));
fprintf('Statistics from middle %6.2f%
fprintf(' Trimmed-mean = %11.4f\n', tmean);
fprintf(' Variance of Trimmed-mean = %11.4f\n\n', tvar);
fprintf(' Winsorized-mean = %11.4f\n', wmean);
fprintf('Variance of Winsorized-mean = %11.4f\n', wvar);
g07dd example results
Statistics from middle 75.00% of data
Trimmed-mean = 8.8333
Variance of Trimmed-mean = 1.5434
Winsorized-mean = 9.1250
Variance of Winsorized-mean = 1.5381
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015