CTPRB
Computes exact probabilities in a two‑way contingency table.
Required Arguments
TABLENROW by NCOL matrix containing the contingency table cell frequencies. (Input)
PRE — Probability of a more extreme table where “extreme” is taken in the Neyman‑Pearson sense. (Output)
A table is more extreme if its probability (for fixed marginals) is less than or equal to PRT.
Optional Arguments
NROW — Number of rows in the contingency table. (Input)
Default: NROW = size (TABLE,1).
NCOL — Number of columns in the contingency table. (Input)
Default: NCOL = size (TABLE,2).
LDTABL — Leading dimension of TABLE exactly as specified in the dimension statement in the calling program. (Input)
Default: LDTABL = size (TABLE,1).
PRT — Probability of the observed table assuming fixed row and column marginal totals. (Output)
PCHEK — Sum of the probabilities of all tables with the same marginal totals. (Output)
PCHEK should be 1.0. Deviation from 1.0 indicates a numerical error.
FORTRAN 90 Interface
Generic: CALL CTPRB (TABLE, PRE [])
Specific: The specific interface names are S_CTPRB and D_CTPRB.
FORTRAN 77 Interface
Single: CALL CTPRB (NROW, NCOL, TABLE, LDTABL, PRT, PRE, PCHEK)
Double: The double precision name is DCTPRB.
Description
Routine CTPRB computes exact probabilities for an r × c contingency table for fixed row and column marginals where r = NROW and c = NCOL. Let fij denote the element in row i and column j of a table, and let fi and fj denote the row and column marginals. Under the independence hypothesis, the (conditional) probability for fixed marginals of a table is given by
where f∙∙ is the total number of counts in the table and x! denotes x factorial. When the fij are obtained from the input table (fij = TABLE(i, j)), Pf = PRT. PRE is the sum over all more extreme tables of the probability of each table.
In CTPRB, a more extreme table is defined in the probabilistic sense. Table X is more extreme than the input table if the conditional probability computed for table X (for the same marginal sums) is less than the conditional probability computed for the input table. The user should note that this definition of “more extreme” can be considered as “two‑sided” in the cell counts.
Because CTPRB uses total enumeration in computing the probability of a more extreme table, the amount of computer time required increases very rapidly with the size of the table. Tables, with either a large total count f∙∙ or in which the product rc is not small, should not be analyzed with CTPRB. Rather, either the approximate methods of Agresti, Wackerly, and Boyett (1979) should be used or algorithms that do not require total enumeration should be used (see Pagano and Halvorsen [1981], or Mehta and Patel [1983]).
Comments
1. Workspace may be explicitly provided, if desired, by use of C2PRB/DC2PRB. The reference is:
CALL C2PRB (NROW, NCOL, TABLE, LDTABL, PRT, PRE, PCHCK, IWK)
The additional argument is:
IWK — Work vector of length (NROW + 2)(NCOL + 2).
2. Informational error
Type
Code
Description
3
1
There are no observed counts in TABLE. PRE, PRT, and PCHEK are set to NaN (not a number).
3. Routine CTPRB computes a two‑tailed Fisher exact probability in 2 by 2 tables. For one‑tailed Fisher exact probabilities, use routine CTTWO.
Example
In this example, CTPRB is used to compute the exact conditional probability for a 2 × 2 contingency table. The input table is given as:
 
USE UMACH_INT
USE CTPRB_INT
 
IMPLICIT NONE
INTEGER NCOL, LDTABL
PARAMETER (NCOL=2, LDTABL=2)
!
INTEGER NOUT
REAL PCHEK, PRE, PRT, TABLE(LDTABL,NCOL)
!
DATA TABLE/8, 8, 12, 2/
!
CALL UMACH (2, NOUT)
!
CALL CTPRB (TABLE, PRE, PRT=PRT, PCHEK=PCHEK)
!
WRITE(NOUT,'('' PRT = '', F12.4, /, '' PRE = '', F12.4, /, &
& '' PCHEK = '', F10.4)') PRT, PRE, PCHEK
END
Output
 
PRT = 0.0390
PRE = 0.0577
PCHEK = 1.0000
Published date: 03/19/2020
Last modified date: 03/19/2020