NAG Library Routine Document
G07DAF finds the median, median absolute deviation, and a robust estimate of the standard deviation for a set of ungrouped data.
||X(N), Y(N), XME, XMD, XSD
The data consists of a sample of size , denoted by , drawn from a random variable .
G07DAF first computes the median,
and from this the median absolute deviation can be computed,
Finally, a robust estimate of the standard deviation is computed,
is the value of the inverse standard Normal function at the point
G07DAF is based upon subroutine LTMDDV within the ROBETH library, see Marazzi (1987)
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
- 1: N – INTEGERInput
On entry: , the number of observations.
- 2: X(N) – REAL (KIND=nag_wp) arrayInput
On entry: the vector of observations, .
- 3: Y(N) – REAL (KIND=nag_wp) arrayOutput
On exit: the observations sorted into ascending order.
- 4: XME – REAL (KIND=nag_wp)Output
On exit: the median, .
- 5: XMD – REAL (KIND=nag_wp)Output
On exit: the median absolute deviation, .
- 6: XSD – REAL (KIND=nag_wp)Output
On exit: the robust estimate of the standard deviation, .
- 7: IFAIL – INTEGERInput/Output
must be set to
. If you are unfamiliar with this parameter you should refer to Section 3.3
in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
. When the value is used it is essential to test the value of IFAIL on exit.
unless the routine detects an error or a warning has been flagged (see Section 6
6 Error Indicators and Warnings
If on entry
, explanatory error messages are output on the current error message unit (as defined by X04AAF
Errors or warnings detected by the routine:
The computations are believed to be stable.
Unless otherwise stated in the Users' Note
, the routine may be called with the same actual array supplied for parameters X
, in which case the sorted data values will overwrite the original contents of X
. However this is not standard Fortran, and may not work on all systems.
The following program reads in a set of data consisting of eleven observations of a variable
. The median, median absolute deviation and a robust estimate of the standard deviation are calculated and printed along with the sorted data in output array Y
9.1 Program Text
Program Text (g07dafe.f90)
9.2 Program Data
Program Data (g07dafe.d)
9.3 Program Results
Program Results (g07dafe.r)