NAG CL Interface
g11sbc (binary_​service)

1 Purpose

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.

2 Specification

#include <nag.h>
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.

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 x̲l=xl1,xl2,,xlp, for l=1,2,,n, denotes the score pattern of the lth 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.

4 References

None.

5 Arguments

1: 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 order=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: order=Nag_RowMajor or Nag_ColMajor.
2: p Integer Input
On entry: p, the number of dichotomous variables.
Constraint: p3.
3: n Integer Input
On entry: n, the number of individuals in the sample.
Constraint: n7.
4: ns Integer * Output
On exit: the number of different score patterns, s.
5: x[dim] Nag_Boolean Input/Output
Note: the dimension, dim, of the array x must be at least
  • max1,pdx×p when order=Nag_ColMajor;
  • max1,n×pdx when order=Nag_RowMajor.
where Xi,j appears in this document, it refers to the array element
  • x[j-1×pdx+i-1] when order=Nag_ColMajor;
  • x[i-1×pdx+j-1] when order=Nag_RowMajor.
On entry: Xi,j must be set equal to Nag_TRUE if xij=1, and Nag_FALSE if xij=0, for i=1,2,,n and j=1,2,,p.
On exit: the first s rows of x contain the s different score patterns.
6: pdx Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array x.
Constraints:
  • if order=Nag_ColMajor, pdxn;
  • if order=Nag_RowMajor, pdxp.
7: irl[n] Integer Output
On exit: the frequency with which the lth row of x occurs, for l=1,2,,s.
8: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error 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.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INT
On entry, n=value.
Constraint: n7.
On entry, p=value.
Constraint: p3.
On entry, pdx=value.
Constraint: pdx>0.
NE_INT_2
On entry, pdx=value and n=value.
Constraint: pdxn.
On entry, pdx=value and p=value.
Constraint: pdxp.
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.

7 Accuracy

Exact.

8 Parallelism and Performance

g11sbc is not threaded in any implementation.

9 Further Comments

The time taken by 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)