# NAG CL Interfaceg11sbc (binary_​service)

Settings help

CL Name Style:

## 1Purpose

g11sbc is a service function which may be used prior to calling g11sac to calculate the frequency distribution of a set of dichotomous score patterns.

## 2Specification

 #include
 void g11sbc (Nag_OrderType order, Integer p, Integer n, Integer *ns, Nag_Boolean x[], Integer pdx, Integer irl[], NagError *fail)
The function may be called by the names: g11sbc, nag_contab_binary_service or nag_binary_factor_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. g11sbc calculates the number of different score patterns, $s$, and the frequency with which each occurs. This information can then be passed to g11sac.

None.

## 5Arguments

1: $\mathbf{order}$Nag_OrderType Input
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 3.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2: $\mathbf{p}$Integer Input
On entry: $p$, the number of dichotomous variables.
Constraint: ${\mathbf{p}}\ge 3$.
3: $\mathbf{n}$Integer Input
On entry: $n$, the number of individuals in the sample.
Constraint: ${\mathbf{n}}\ge 7$.
4: $\mathbf{ns}$Integer * Output
On exit: the number of different score patterns, $s$.
5: $\mathbf{x}\left[\mathit{dim}\right]$Nag_Boolean Input/Output
Note: the dimension, dim, of the array x must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdx}}×{\mathbf{p}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×{\mathbf{pdx}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
where ${\mathbf{X}}\left(i,j\right)$ appears in this document, it refers to the array element
• ${\mathbf{x}}\left[\left(j-1\right)×{\mathbf{pdx}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{x}}\left[\left(i-1\right)×{\mathbf{pdx}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: ${\mathbf{X}}\left(\mathit{i},\mathit{j}\right)$ must be set equal to Nag_TRUE if ${x}_{\mathit{i}\mathit{j}}=1$, and Nag_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.
6: $\mathbf{pdx}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array x.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${\mathbf{pdx}}\ge {\mathbf{n}}$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdx}}\ge {\mathbf{p}}$.
7: $\mathbf{irl}\left[{\mathbf{n}}\right]$Integer Output
On exit: the frequency with which the $\mathit{l}$th row of x occurs, for $\mathit{l}=1,2,\dots ,s$.
8: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error 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.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_INT
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 7$.
On entry, ${\mathbf{p}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{p}}\ge 3$.
On entry, ${\mathbf{pdx}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdx}}>0$.
NE_INT_2
On entry, ${\mathbf{pdx}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdx}}\ge {\mathbf{n}}$.
On entry, ${\mathbf{pdx}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{p}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdx}}\ge {\mathbf{p}}$.
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.

Exact.

## 8Parallelism and Performance

g11sbc is not threaded in any implementation.

The time taken by g11sbc 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 (g11sbce.c)

### 10.2Program Data

Program Data (g11sbce.d)

### 10.3Program Results

Program Results (g11sbce.r)