g11 Chapter Contents
g11 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_binary_factor_service (g11sbc)

## 1  Purpose

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

## 2  Specification

 #include #include
 void nag_binary_factor_service (Nag_OrderType order, Integer p, Integer n, Integer *ns, Nag_Boolean x[], Integer pdx, Integer irl[], NagError *fail)

## 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. nag_binary_factor_service (g11sbc) calculates the number of different score patterns, $s$, and the frequency with which each occurs. This information can then be passed to nag_binary_factor (g11sac).

None.

## 5  Arguments

1:    $\mathbf{order}$Nag_OrderTypeInput
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 2.3.1.3 in How to Use the NAG Library and its Documentation for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2:    $\mathbf{p}$IntegerInput
On entry: $p$, the number of dichotomous variables.
Constraint: ${\mathbf{p}}\ge 3$.
3:    $\mathbf{n}$IntegerInput
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_BooleanInput/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}$IntegerInput
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]$IntegerOutput
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 2.7 in How to Use the NAG Library and its Documentation).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation 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 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.

Exact.

## 8  Parallelism and Performance

nag_binary_factor_service (g11sbc) is not threaded in any implementation.

The time taken by nag_binary_factor_service (g11sbc) is small and increases with $n$.

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

### 10.1  Program Text

Program Text (g11sbce.c)

### 10.2  Program Data

Program Data (g11sbce.d)

### 10.3  Program Results

Program Results (g11sbce.r)