# NAG FL Interfaceg11sbf (binary_​service)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

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.

## 2Specification

Fortran Interface
 Subroutine g11sbf ( ip, n, ns, x, ldx, irl,
 Integer, Intent (In) :: ip, n, ldx Integer, Intent (Inout) :: ifail Integer, Intent (Out) :: ns, irl(n) Logical, Intent (Inout) :: x(ldx,ip)
#include <nag.h>
 void g11sbf_ (const Integer *ip, const Integer *n, Integer *ns, logical x[], const Integer *ldx, Integer irl[], Integer *ifail)
The routine may be called by the names g11sbf or nagf_contab_binary_service.

## 3Description

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.

## 5Arguments

1: $\mathbf{ip}$Integer Input
On entry: $p$, the number of dichotomous variables.
Constraint: ${\mathbf{ip}}\ge 3$.
2: $\mathbf{n}$Integer Input
On entry: $n$, the number of individuals in the sample.
Constraint: ${\mathbf{n}}\ge 7$.
3: $\mathbf{ns}$Integer Output
On exit: the number of different score patterns, $s$.
4: $\mathbf{x}\left({\mathbf{ldx}},{\mathbf{ip}}\right)$Logical array Input/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: $\mathbf{ldx}$Integer Input
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: $\mathbf{irl}\left({\mathbf{n}}\right)$Integer array Output
On exit: the frequency with which the $\mathit{l}$th row of x occurs, for $\mathit{l}=1,2,\dots ,s$.
7: $\mathbf{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 $-\mathbf{1}$ 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).

## 6Error Indicators and Warnings

If on entry ${\mathbf{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:
${\mathbf{ifail}}=1$
On entry, ${\mathbf{ip}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ip}}\ge 3$.
On entry, ${\mathbf{ldx}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ldx}}\ge {\mathbf{n}}$.
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 7$.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{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.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

Exact.

## 8Parallelism and Performance

g11sbf is not threaded in any implementation.

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

## 10Example

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

### 10.1Program Text

Program Text (g11sbfe.f90)

### 10.2Program Data

Program Data (g11sbfe.d)

### 10.3Program Results

Program Results (g11sbfe.r)