NAG CL Interface
g01dcc (normal_​scores_​var)

Settings help

CL Name Style:


1 Purpose

g01dcc computes an approximation to the variance-covariance matrix of an ordered set of independent observations from a Normal distribution with mean 0.0 and standard deviation 1.0.

2 Specification

#include <nag.h>
void  g01dcc (Integer n, double exp1, double exp2, double sumssq, double vec[], NagError *fail)
The function may be called by the names: g01dcc, nag_stat_normal_scores_var or nag_normal_scores_var.

3 Description

g01dcc is an adaptation of the Applied Statistics Algorithm AS 128, see Davis and Stephens (1978). An approximation to the variance-covariance matrix, V, using a Taylor series expansion of the Normal distribution function is discussed in David and Johnson (1954).
However, convergence is slow for extreme variances and covariances. The present function uses the David–Johnson approximation to provide an initial approximation and improves upon it by use of the following identities for the matrix.
For a sample of size n, let mi be the expected value of the ith largest order statistic, then:
  1. (a)for any i=1,2,,n, j=1nVij=1
  2. (b)V12=V11+mn2-mnmn-1-1
  3. (c)the trace of V is tr(V)=n-i=1nmi2
  4. (d)Vij=Vji=Vrs=Vsr where r=n+1-i, s=n+1-j and i,j=1,2,,n. Note that only the upper triangle of the matrix is calculated and returned column-wise in vector form.

4 References

David F N and Johnson N L (1954) Statistical treatment of censored data, Part 1. Fundamental formulae Biometrika 41 228–240
Davis C S and Stephens M A (1978) Algorithm AS 128: approximating the covariance matrix of Normal order statistics Appl. Statist. 27 206–212

5 Arguments

1: n Integer Input
On entry: n, the sample size.
Constraint: n>0.
2: exp1 double Input
On entry: the expected value of the largest Normal order statistic, mn, from a sample of size n.
3: exp2 double Input
On entry: the expected value of the second largest Normal order statistic, mn-1, from a sample of size n.
4: sumssq double Input
On entry: the sum of squares of the expected values of the Normal order statistics from a sample of size n.
5: vec[n×(n+1)/2] double Output
On exit: the upper triangle of the n×n variance-covariance matrix packed by column. Thus element Vij is stored in vec[i+j×(j-1)/2-1], for 1ijn.
6: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INT
On entry, n=value.
Constraint: n>0.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.

7 Accuracy

For n20, where comparison with the exact values can be made, the maximum error is less than 0.0001.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
g01dcc is not threaded in any implementation.

9 Further Comments

The time taken by g01dcc is approximately proportional to n2.
The arguments exp1 (=mn), exp2 (=mn-1) and sumssq (=j=1nmj2) may be found from the expected values of the Normal order statistics obtained from g01dac .

10 Example

A program to compute the variance-covariance matrix for a sample of size 6. g01dac is called to provide values for exp1, exp2 and sumssq.

10.1 Program Text

Program Text (g01dcce.c)

10.2 Program Data

None.

10.3 Program Results

Program Results (g01dcce.r)