G11SBF (PDF version)
G11 Chapter Contents
G11 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG11SBF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

G11SBF is a service routine which may be used prior to calling G11SAF to calculate the frequency distribution of a set of dichotomous score patterns.

## 2  Specification

 SUBROUTINE G11SBF ( IP, N, NS, X, LDX, IRL, IFAIL)
 INTEGER IP, N, NS, LDX, IRL(N), IFAIL LOGICAL X(LDX,IP)

## 3  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 ${\underline{x}}_{\mathit{l}}=\left({x}_{\mathit{l}1},{x}_{\mathit{l}2},\dots ,{x}_{\mathit{l}p}\right)$, for $\mathit{l}=1,2,\dots ,n$, denotes the score pattern of the $l$th individual. G11SBF calculates the number of different score patterns, $s$, and the frequency with which each occurs. This information can then be passed to G11SAF.

None.

## 5  Parameters

1:     IP – INTEGERInput
On entry: $p$, the number of dichotomous variables.
Constraint: ${\mathbf{IP}}\ge 3$.
2:     N – INTEGERInput
On entry: $n$, the number of individuals in the sample.
Constraint: ${\mathbf{N}}\ge 7$.
3:     NS – INTEGEROutput
On exit: the number of different score patterns, $s$.
4:     X(LDX,IP) – LOGICAL arrayInput/Output
On entry: ${\mathbf{X}}\left(\mathit{i},\mathit{j}\right)$ must be set equal to .TRUE. if ${x}_{\mathit{i}\mathit{j}}=1$, and .FALSE. if ${x}_{\mathit{i}\mathit{j}}=0$, for $\mathit{i}=1,2,\dots ,n$ and $\mathit{j}=1,2,\dots ,p$.
On exit: the first $s$ rows of X contain the $s$ different score patterns.
5:     LDX – INTEGERInput
On entry: the first dimension of the array X as declared in the (sub)program from which G11SBF is called.
Constraint: ${\mathbf{LDX}}\ge {\mathbf{N}}$.
6:     IRL(N) – INTEGER arrayOutput
On exit: the frequency with which the $\mathit{l}$th row of X occurs, for $\mathit{l}=1,2,\dots ,s$.
7:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{IP}}<3$, or ${\mathbf{N}}<7$, or ${\mathbf{LDX}}<{\mathbf{N}}$.

Exact.

## 8  Further Comments

The time taken by G11SBF is small and increases with $n$.

## 9  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

### 9.1  Program Text

Program Text (g11sbfe.f90)

### 9.2  Program Data

Program Data (g11sbfe.d)

### 9.3  Program Results

Program Results (g11sbfe.r)

G11SBF (PDF version)
G11 Chapter Contents
G11 Chapter Introduction
NAG Library Manual