NAG Library Routine Document
g07daf (robust_1var_median)
1
Purpose
g07daf finds the median, median absolute deviation, and a robust estimate of the standard deviation for a set of ungrouped data.
2
Specification
Fortran Interface
Integer, Intent (In) | :: | n | Integer, Intent (Inout) | :: | ifail | Real (Kind=nag_wp), Intent (In) | :: | x(n) | Real (Kind=nag_wp), Intent (Out) | :: | y(n), xme, xmd, xsd |
|
C Header Interface
#include <nagmk26.h>
void |
g07daf_ (const Integer *n, const double x[], double y[], double *xme, double *xmd, double *xsd, Integer *ifail) |
|
3
Description
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,
where
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).
4
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
5
Arguments
- 1: – IntegerInput
-
On entry: , the number of observations.
Constraint:
.
- 2: – Real (Kind=nag_wp) arrayInput
-
On entry: the vector of observations, .
- 3: – Real (Kind=nag_wp) arrayOutput
-
On exit: the observations sorted into ascending order.
- 4: – Real (Kind=nag_wp)Output
-
On exit: the median, .
- 5: – Real (Kind=nag_wp)Output
-
On exit: the median absolute deviation, .
- 6: – Real (Kind=nag_wp)Output
-
On exit: the robust estimate of the standard deviation, .
- 7: – IntegerInput/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation 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 argument, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
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
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7
Accuracy
The computations are believed to be stable.
8
Parallelism and Performance
g07daf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g07daf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
Unless otherwise stated in the
Users' Note, the routine may be called with the same actual array supplied for arguments
x and
y, 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.
10
Example
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.
10.1
Program Text
Program Text (g07dafe.f90)
10.2
Program Data
Program Data (g07dafe.d)
10.3
Program Results
Program Results (g07dafe.r)