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

NAG Library Routine Document


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.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

G11BCF computes a marginal table from a table computed by G11BAF or G11BBF using a selected statistic.

2  Specification


3  Description

For a dataset containing classification variables (known as factors) the routines G11BAF and G11BBF compute a table using selected statistics, for example the mean or the median. The table is indexed by the levels of the selected factors, for example if there were three factors A, B and C with 3, 2 and 4 levels respectively and the mean was to be tabulated the resulting table would be 3×2×4 with each cell being the mean of all observations with the appropriate combination of levels of the three factors. In further analysis the table of means averaged over C for A and B may be required; this can be computed from the full table by taking the mean over the third dimension of the table, C.
In general, given a table computed by G11BAF or G11BBF, G11BCF computes a sub-table defined by a subset of the factors used to define the table such that each cell of the sub-table is the selected statistic computed over the remaining factors. The statistics that can be used are the total, the mean, the median, the variance, the smallest and the largest value.

4  References

John J A and Quenouille M H (1977) Experiments: Design and Analysis Griffin
Kendall M G and Stuart A (1969) The Advanced Theory of Statistics (Volume 1) (3rd Edition) Griffin
West D H D (1979) Updating mean and variance estimates: An improved method Comm. ACM 22 532–555

5  Parameters

1:     STAT – CHARACTER(1)Input
On entry: indicates which statistic is to be used to compute the marginal table.
The total.
The average or mean.
The median.
The variance.
The largest value.
The smallest value.
Constraint: STAT='T', 'A', 'M', 'V', 'L' or 'S'.
2:     TABLE(NCELLS) – REAL (KIND=nag_wp) arrayInput
On entry: the table as computed by G11BAF or G11BBF.
3:     NCELLS – INTEGERInput
On entry: the number of cells in TABLE as returned by G11BAF or G11BBF.
4:     NDIM – INTEGERInput
On entry: the number of dimensions for TABLE as returned by G11BAF or G11BBF.
Constraint: NDIM2.
5:     IDIM(NDIM) – INTEGER arrayInput
On entry: the number of levels for each dimension of TABLE as returned by G11BAF or G11BBF.
Constraint: IDIMi2, for i=1,2,,NDIM.
6:     ISDIM(NDIM) – INTEGER arrayInput
On entry: indicates which dimensions of TABLE are to be included in the sub-table. If ISDIMi>0 the dimension or factor indicated by IDIMi is to be included in the sub-table, otherwise it is excluded.
7:     STABLE(MAXST) – REAL (KIND=nag_wp) arrayOutput
On exit: the first MCELLS elements contain the sub-table computed using the statistic indicated by STAT. The table is stored in a similar way to TABLE with the MCELLS cells stored so that for any two dimensions the index relating to the dimension given later in IDIM changes faster. For further details see Section 8.
8:     MAXST – INTEGERInput
On entry: the maximum size of sub-table to be computed.
Constraint: MAXST the product of the levels of the dimensions of TABLE included in the sub-table, STABLE.
9:     MCELLS – INTEGEROutput
On exit: the number of cells in the sub-table in STABLE.
10:   MDIM – INTEGEROutput
On exit: the number of dimensions to the sub-table in STABLE.
11:   MLEVEL(NDIM) – INTEGER arrayOutput
On exit: the first MDIM elements contain the number of levels for the dimensions of the sub-table in STABLE. The remaining elements are not referenced.
12:   AUXT(*) – REAL (KIND=nag_wp) arrayOutput
Note: the dimension of the array AUXT must be at least MAXST if STAT='V', and at least 1 otherwise.
On exit: if STAT='V' AUXT contains the sub-table of means corresponding to the sub-table of variances in STABLE. Otherwise AUXT is not referenced.
13:   IWK(3×NDIM) – INTEGER arrayWorkspace
14:   WK(NCELLS) – REAL (KIND=nag_wp) arrayWorkspace
15:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ 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​ 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 -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry 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:
On entry,NDIM<2,
orSTAT'T', 'A', 'M', 'V', 'L' or 'S'.
On entry,IDIMi1, for some i=1,2,,NDIM,
orNCELLS is incompatible with IDIM,
orthe requested sub-table is of dimension 0,
orthe requested sub-table is the full table,
orMAXST is too small, the minimum value is returned in MDIM.

7  Accuracy

Only applicable when STAT='V'. In this case a one pass algorithm is used as describe in West (1979).

8  Further Comments

The sub-tables created by G11BCF and stored in STABLE and, depending on STAT, also in AUXT are stored in the following way. Let there be m dimensions defining the table with dimension k having lk levels, then the cell defined by the levels i1,i2,,im of the factors is stored in sth cell given by
cj=k=j+ 1m lk   for ​ j= 1, 2,, n- 1   and   cm=1.

9  Example

The data, given by John and Quenouille (1977), is for 3 blocks of a 3×6 factorial experiment. The data can be considered as a 3×6×3 table (i.e., blocks × treatment with 6 levels × treatment with 3 levels). This table is input and the 6×3 table of treatment means for over blocks is computed and printed.

9.1  Program Text

Program Text (g11bcfe.f90)

9.2  Program Data

Program Data (g11bcfe.d)

9.3  Program Results

Program Results (g11bcfe.r)

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

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012