NAG Library Routine Document
G11BCF computes a marginal table from a table computed by G11BAF
using a selected statistic.
|SUBROUTINE G11BCF (
||STAT, TABLE, NCELLS, NDIM, IDIM, ISDIM, STABLE, MAXST, MCELLS, MDIM, MLEVEL, AUXT, IWK, WK, IFAIL)
||NCELLS, NDIM, IDIM(NDIM), ISDIM(NDIM), MAXST, MCELLS, MDIM, MLEVEL(NDIM), IWK(3*NDIM), IFAIL
||TABLE(NCELLS), STABLE(MAXST), AUXT(*), WK(NCELLS)
For a dataset containing classification variables (known as factors) the routines G11BAF
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
levels respectively and the mean was to be tabulated the resulting table would be
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
, 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.
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
- 1: STAT – CHARACTER(1)Input
: 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.
, , , , or .
- 2: TABLE(NCELLS) – REAL (KIND=nag_wp) arrayInput
: the table as computed by G11BAF
- 3: NCELLS – INTEGERInput
: the number of cells in TABLE
as returned by G11BAF
- 4: NDIM – INTEGERInput
: the number of dimensions for TABLE
as returned by G11BAF
- 5: IDIM(NDIM) – INTEGER arrayInput
: the number of levels for each dimension of TABLE
as returned by G11BAF
, for .
- 6: ISDIM(NDIM) – INTEGER arrayInput
: indicates which dimensions of TABLE
are to be included in the sub-table. If
the dimension or factor indicated by
is to be included in the sub-table, otherwise it is excluded.
- 7: STABLE(MAXST) – REAL (KIND=nag_wp) arrayOutput
: 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.
the product of the levels of the dimensions of TABLE
included in the sub-table, STABLE
- 9: MCELLS – INTEGEROutput
: the number of cells in the sub-table in STABLE
- 10: MDIM – INTEGEROutput
: the number of dimensions to the sub-table in STABLE
- 11: MLEVEL(NDIM) – INTEGER arrayOutput
: 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
the dimension of the array AUXT
must be at least
, and at least
: if AUXT
contains the sub-table of means corresponding to the sub-table of variances in STABLE
. Otherwise AUXT
is not referenced.
- 13: IWK() – INTEGER arrayWorkspace
- 14: WK(NCELLS) – REAL (KIND=nag_wp) arrayWorkspace
- 15: IFAIL – INTEGERInput/Output
must be set to
. 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
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
. When the value is used it is essential to test the value of IFAIL on exit.
unless the routine detects an error or a warning has been flagged (see Section 6
6 Error Indicators and Warnings
If on entry
, explanatory error messages are output on the current error message unit (as defined by X04AAF
Errors or warnings detected by the routine:
|or||, , , , or .|
|On entry,||, for some ,|
|or||NCELLS is incompatible with IDIM,|
|or||the requested sub-table is of dimension ,|
|or||the requested sub-table is the full table,|
|or||MAXST is too small, the minimum value is returned in MDIM.|
Only applicable when
. In this case a one pass algorithm is used as describe in West (1979)
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
dimensions defining the table with dimension
levels, then the cell defined by the levels
of the factors is stored in
th cell given by
The data, given by John and Quenouille (1977)
, is for 3 blocks of a
factorial experiment. The data can be considered as a
table (i.e., blocks
levels). This table is input and the
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)