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_contab_binary_service (g11sb)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_contab_binary_service (g11sb) is a service function which may be used prior to calling nag_contab_binary (g11sa) to calculate the frequency distribution of a set of dichotomous score patterns.

Syntax

[ns, x, irl, ifail] = g11sb(x, 'ip', ip, 'n', n)
[ns, x, irl, ifail] = nag_contab_binary_service(x, 'ip', ip, 'n', n)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 22: n was made optional

Description

When each of n individuals responds to each of p dichotomous variables the data assumes the form of the matrix X defined below
X= x11 x12 x1p x21 x22 x2p xn1 xn2 xnp = x̲1 x̲2 x̲n ,  
where the x take the value of 0 or 1 and x̲l=xl1,xl2,,xlp, for l=1,2,,n, denotes the score pattern of the lth individual. nag_contab_binary_service (g11sb) calculates the number of different score patterns, s, and the frequency with which each occurs. This information can then be passed to nag_contab_binary (g11sa).

References

None.

Parameters

Compulsory Input Parameters

1:     xldxip – logical array
ldx, the first dimension of the array, must satisfy the constraint ldxn.
xij must be set equal to true if xij=1, and false if xij=0, for i=1,2,,n and j=1,2,,p.

Optional Input Parameters

1:     ip int64int32nag_int scalar
Default: the second dimension of the array x.
p, the number of dichotomous variables.
Constraint: ip3.
2:     n int64int32nag_int scalar
Default: the first dimension of the array x.
n, the number of individuals in the sample.
Constraint: n7.

Output Parameters

1:     ns int64int32nag_int scalar
The number of different score patterns, s.
2:     xldxip – logical array
The first s rows of x contain the s different score patterns.
3:     irln int64int32nag_int array
The frequency with which the lth row of x occurs, for l=1,2,,s.
4:     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,ip<3,
orn<7,
orldx<n.
   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

Exact.

Further Comments

The time taken by nag_contab_binary_service (g11sb) is small and increases with n.

Example

This example counts the frequencies of different score patterns in the following list:
Score Patterns
000
010
111
000
001
000
000
110
001
011
function g11sb_example


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

x = [false, false, false;
     false, true,  false;
     true,  true,  true;
     false, false, false;
     false, false, true;
     false, false, false;
     false, false, false;
     true,  true,  false;
     false, false, true;
     false, true,  true];

[ns, x, irl, ifail] = g11sb(x);

% Display results
fprintf('Frequency     Score pattern\n\n');
for i = 1:ns
  fprintf('%5d            ', irl(i));
  fprintf('%2d', x(i,:));
  fprintf('\n');
end


g11sb example results

Frequency     Score pattern

    4             0 0 0
    1             0 1 0
    1             1 1 1
    2             0 0 1
    1             1 1 0
    1             0 1 1

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