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_stat_ranks_and_scores (g01dh)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_stat_ranks_and_scores (g01dh) computes the ranks, Normal scores, an approximation to the Normal scores or the exponential scores as requested by you.

Syntax

[r, ifail] = g01dh(scores, ties, x, 'n', n)
[r, ifail] = nag_stat_ranks_and_scores(scores, ties, x, 'n', n)

Description

nag_stat_ranks_and_scores (g01dh) computes one of the following scores for a sample of observations, x1,x2,,xn.
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. 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 EZk 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. 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. 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 = EYk = 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 xti, for i=1,2,,m, denote m tied observations, that is xt1=xt2==xtm with t1<t2<<tm. If the rank of xt1 is k, then if ties are ignored the rank of xtj will be k+j-1. Let the scores ignoring ties be st1*,st2*,,stm*. Then the scores, sti, for i=1,2,,m, may be calculated as follows:

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

Parameters

Compulsory Input Parameters

1:     scores – string (length ≥ 1)
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 – string (length ≥ 1)
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:     xn – double array
The sample of observations, xi, for i=1,2,,n.

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the dimension of the array x.
n, the number of observations.
Constraint: n1.

Output Parameters

1:     rn – double array
Contains the scores, si, for i=1,2,,n, as specified by scores.
2:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
On entry,scores'R', 'N', 'B', 'T', 'V' or 'S',
orties'A', 'L', 'H', 'N', 'R' or 'I',
orn<1.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

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 max100×ε,10-8 where ε is the machine precision.
For scores='B', 'T' or 'V', the results should have a relative accuracy of at least max10×ε,10-12.

Further Comments

If more accurate Normal scores are required nag_stat_normal_scores_exact (g01da) should be used with appropriate settings for the input argument etol.

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.
function g01dh_example


fprintf('g01dh example results\n\n');

scores = 'Savage';
ties   = 'Average';
x      = [2;     0;     2;     2;     0];

[r, ifail] = g01dh( ...
                    scores, ties, x);

% Display results
fprintf('Scores: %s\n', scores);
fprintf('Ties  : %s\n', ties);
fprintf('Ranks : \n\n');
disp(r);


g01dh example results

Scores: Savage
Ties  : Average
Ranks : 

    1.4500
    0.3250
    1.4500
    1.4500
    0.3250


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–2015