# calcTall: Calculate all Tstat for all values of the (n1+1) X (n2+1)... In exact2x2: Exact Tests and Confidence Intervals for 2x2 Tables

## Description

Used mostly by internal call from `uncondExact2x2`. If `EplusM=FALSE` and `tiebreak=FALSE` then the result is just `Tstat(allx,n1,ally,n2,delta0)`. Otherwise does more complicated calculations.

## Usage

 ```1 2``` ```calcTall(Tstat, allx, n1, ally, n2, delta0 = 0, parmtype = "difference", alternative = "two.sided", tsmethod = "central", EplusM = FALSE, tiebreak = FALSE) ```

## Arguments

 `Tstat` ordering function `allx` vector of x1 values, typically rep(0:n1,n2+1) `n1` sample size in group 1 `ally` vector of x2 values, typically rep(0:n2,each=n1+1) `n2` sample size in group 2 `delta0` null parameter value for input into Tstat `parmtype` parmeter type, either 'difference', 'ratio', or 'oddsratio' `alternative` alternative hypothesis, either 'two.sided' or not `tsmethod` two-sided method, either 'central' or 'square' `EplusM` logical, do E+M ordering of Lloyd (2008)? `tiebreak` logical, do tie break method? Only allowed when tsmethod!='square'.

## Details

When `tiebreak=TRUE` does a method that breaks ties in the ordering function differently depending on the `parmtype` value. The tie breaks are developed to make sense when `method="simple"` and `tsmethod!="square"`, when applied to other methods it may not necessarily break ties reasonably. For that reason `tiebreak=TRUE` returns an error when `tsmethod="square"`. For `parmtype="difference"` ties are broken based on Z scores on the difference in proportions, with larger values of `Z` treated as larger. This means that when the sample proportions are equal, the ties are not broken. For `parmtype="ratio"` ties are broken based on `abs(Z)`, where the Z scores are based on the difference in log proportions, except when x1=0 (when ties are broken by x2) or x2=0 (when ties are broken by 1/x1). For `parmtype="oddsratio"` ties are broken based on `abs(Z)`, where here the Z scores are based on the difference in log odds, except when x1=0 or x1=n1 or x2=0 or x2=n2 (see code for specifics).

The E+M method, is to take an existing ordering function, Tstat, and calculate a one-sided p-value based on that ordering function evaluated at the constrained maximum likelihood estimates of the parameters. The ordering is then the set of one-sided p-values from Pr[T(X)<=T(xobs)], except when `alternative="two.sided"` and `tsmethod="square"` in which case it is 1-p, where p, the p-value, is based on Pr[T(X)>=T(xobs)]. The latter exception is needed so that larger values are more likely to reject.

If `tiebreak=TRUE` and `EplusM=TRUE`, the teibreak calculations are always done first.

## Value

a vector of the same length as allx, giving values of Tstat function at all values in the sample space.

exact2x2 documentation built on Dec. 11, 2021, 9:43 a.m.