NAG FL Interface
g01dhf (ranks_​and_​scores)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

g01dhf computes the ranks, Normal scores, an approximation to the Normal scores or the exponential scores as requested by you.

2 Specification

Fortran Interface
Subroutine g01dhf ( scores, ties, n, x, r, iwrk, ifail)
Integer, Intent (In) :: n
Integer, Intent (Inout) :: ifail
Integer, Intent (Out) :: iwrk(n)
Real (Kind=nag_wp), Intent (In) :: x(n)
Real (Kind=nag_wp), Intent (Out) :: r(n)
Character (1), Intent (In) :: scores, ties
C Header Interface
#include <nag.h>
void  g01dhf_ (const char *scores, const char *ties, const Integer *n, const double x[], double r[], Integer iwrk[], Integer *ifail, const Charlen length_scores, const Charlen length_ties)
The routine may be called by the names g01dhf or nagf_stat_ranks_and_scores.

3 Description

g01dhf computes one of the following scores for a sample of observations, x1,x2,,xn.
  1. 1.Rank Scores
    The ranks are assigned to the data in ascending order, that is the ith observation has score si=k if it is the kth smallest observation in the sample.
  2. 2.Normal Scores
    The Normal scores are the expected values of the Normal order statistics from a sample of size n. If xi is the kth smallest observation in the sample, then the score for that observation, si, is E(Zk) where Zk is the kth order statistic in a sample of size n from a standard Normal distribution and E is the expectation operator.
  3. 3.Blom, Tukey and van der Waerden Scores
    These scores are approximations to the Normal scores. The scores are obtained by evaluating the inverse cumulative Normal distribution function, Φ-1(·), at the values of the ranks scaled into the interval (0,1) using different scaling transformations.
    The Blom scores use the scaling transformation ri-38 n+14 for the rank ri, for i=1,2,,n. Thus the Blom score corresponding to the observation xi is
    si = Φ-1 ( ri - 38 n+14 ) .  
    The Tukey scores use the scaling transformation ri-13 n+13 ; the Tukey score corresponding to the observation xi is
    si = Φ-1 ( ri - 13 n+13 ) .  
    The van der Waerden scores use the scaling transformation rin+1; the van der Waerden score corresponding to the observation xi is
    si = Φ-1 ( ri n+1 ) .  
    The van der Waerden scores may be used to carry out the van der Waerden test for testing for differences between several population distributions, see Conover (1980).
  4. 4.Savage Scores
    The Savage scores are the expected values of the exponential order statistics from a sample of size n. They may be used in a test discussed by Savage (1956) and Lehmann (1975). If xi is the kth smallest observation in the sample, then the score for that observation is
    si = E(Yk) = 1n + 1n-1 + + 1n-k+1 ,  
    where Yk is the kth order statistic in a sample of size n from a standard exponential distribution and E is the expectation operator.
Ties may be handled in one of five ways. Let xt(i), for i=1,2,,m, denote m tied observations, that is xt(1)=xt(2)==xt(m) with t(1)<t(2)<<t(m). If the rank of xt(1) is k, then if ties are ignored the rank of xt(j) will be k+j-1. Let the scores ignoring ties be st(1)*,st(2)*,,st(m)*. Then the scores, st(i), for i=1,2,,m, may be calculated as follows:

4 References

Blom G (1958) Statistical Estimates and Transformed Beta-variables Wiley
Conover W J (1980) Practical Nonparametric Statistics Wiley
Lehmann E L (1975) Nonparametrics: Statistical Methods Based on Ranks Holden–Day
Savage I R (1956) Contributions to the theory of rank order statistics – the two-sample case Ann. Math. Statist. 27 590–615
Tukey J W (1962) The future of data analysis Ann. Math. Statist. 33 1–67

5 Arguments

1: scores Character(1) Input
On entry: indicates which of the following scores are required.
scores='R'
The ranks.
scores='N'
The Normal scores, that is the expected value of the Normal order statistics.
scores='B'
The Blom version of the Normal scores.
scores='T'
The Tukey version of the Normal scores.
scores='V'
The van der Waerden version of the Normal scores.
scores='S'
The Savage scores, that is the expected value of the exponential order statistics.
Constraint: scores='R', 'N', 'B', 'T', 'V' or 'S'.
2: ties Character(1) Input
On entry: indicates which of the following methods is to be used to assign scores to tied observations.
ties='A'
The average of the scores for tied observations is used.
ties='L'
The lowest score in the group of ties is used.
ties='H'
The highest score in the group of ties is used.
ties='N'
The nonrepeatable random number generator is used to randomly untie any group of tied observations.
ties='R'
The repeatable random number generator is used to randomly untie any group of tied observations.
ties='I'
Any ties are ignored, that is the scores are assigned to tied observations in the order that they appear in the data.
Constraint: ties='A', 'L', 'H', 'N', 'R' or 'I'.
3: n Integer Input
On entry: n, the number of observations.
Constraint: n1.
4: x(n) Real (Kind=nag_wp) array Input
On entry: the sample of observations, xi, for i=1,2,,n.
5: r(n) Real (Kind=nag_wp) array Output
On exit: contains the scores, si, for i=1,2,,n, as specified by scores.
6: iwrk(n) Integer array Workspace
7: ifail Integer Input/Output
On entry: ifail must be set to 0, -1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of -1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value -1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, n=value.
Constraint: n1.
On entry, scores=value.
Constraint: scores='R', 'N', 'B', 'T', 'V' or 'S'.
On entry, ties=value.
Constraint: ties='A', 'L', 'H', 'R' or 'I'.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

For scores='R', the results should be accurate to machine precision.
For scores='S', the results should be accurate to a small multiple of machine precision.
For scores='N', the results should have a relative accuracy of at least max(100×ε,10-8) where ε is the machine precision.
For scores='B', 'T' or 'V', the results should have a relative accuracy of at least max(10×ε,10-12).

8 Parallelism and Performance

g01dhf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
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.

9 Further Comments

If more accurate Normal scores are required g01daf should be used with appropriate settings for the input argument etol.

10 Example

This example computes and prints the Savage scores for a sample of five observations. The average of the scores of any tied observations is used.

10.1 Program Text

Program Text (g01dhfe.f90)

10.2 Program Data

Program Data (g01dhfe.d)

10.3 Program Results

Program Results (g01dhfe.r)