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_median (g07da)

Purpose

nag_univar_robust_1var_median (g07da) finds the median, median absolute deviation, and a robust estimate of the standard deviation for a set of ungrouped data.

Syntax

[y, xme, xmd, xsd, ifail] = g07da(x, 'n', n)
[y, xme, xmd, xsd, ifail] = nag_univar_robust_1var_median(x, 'n', n)

Description

The data consists of a sample of size nn, denoted by x1,x2,,xnx1,x2,,xn, drawn from a random variable XX.
nag_univar_robust_1var_median (g07da) first computes the median,
θmed = medi{xi},
θmed=medi{xi},
and from this the median absolute deviation can be computed,
σmed = medi{|xiθmed|}.
σmed=medi{|xi-θmed|}.
Finally, a robust estimate of the standard deviation is computed,
σmed = σmed / Φ1(0.75)
σmed=σmed/Φ-1(0.75)
where Φ1(0.75)Φ-1(0.75) is the value of the inverse standard Normal function at the point 0.750.75.
nag_univar_robust_1var_median (g07da) is based upon function LTMDDV within the ROBETH library, see Marazzi (1987).

References

Huber P J (1981) Robust Statistics Wiley
Marazzi A (1987) Subroutines for robust estimation of location and scale in ROBETH Cah. Rech. Doc. IUMSP, No. 3 ROB 1 Institut Universitaire de Médecine Sociale et Préventive, Lausanne

Parameters

Compulsory Input Parameters

1:     x(n) – double array
n, the dimension of the array, must satisfy the constraint n > 1n>1.
The vector of observations, x1,x2,,xnx1,x2,,xn.

Optional Input Parameters

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

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     y(n) – double array
The observations sorted into ascending order.
2:     xme – double scalar
The median, θmedθmed.
3:     xmd – double scalar
The median absolute deviation, σmedσmed.
4:     xsd – double scalar
The robust estimate of the standard deviation, σmedσmed.
5:     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.

Accuracy

The computations are believed to be stable.

Further Comments

None.

Example

function nag_univar_robust_1var_median_example
x = [13;
     11;
     16;
     5;
     3;
     18;
     9;
     8;
     6;
     27;
     7];
[y, xme, xmd, xsd, ifail] = nag_univar_robust_1var_median(x)
 

y =

     3
     5
     6
     7
     8
     9
    11
    13
    16
    18
    27


xme =

     9


xmd =

     4


xsd =

    5.9304


ifail =

                    0


function g07da_example
x = [13;
     11;
     16;
     5;
     3;
     18;
     9;
     8;
     6;
     27;
     7];
[y, xme, xmd, xsd, ifail] = g07da(x)
 

y =

     3
     5
     6
     7
     8
     9
    11
    13
    16
    18
    27


xme =

     9


xmd =

     4


xsd =

    5.9304


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