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.
calcTall(Tstat, allx, n1, ally, n2, delta0 = 0, parmtype = "difference",
alternative = "two.sided", tsmethod = "central", EplusM = FALSE, tiebreak = FALSE)
a vector of the same length as allx, giving values of Tstat function at all values in the sample space.
ordering function
vector of x1 values, typically rep(0:n1,n2+1)
sample size in group 1
vector of x2 values, typically rep(0:n2,each=n1+1)
sample size in group 2
null parameter value for input into Tstat
parmeter type, either 'difference', 'ratio', or 'oddsratio'
alternative hypothesis, either 'two.sided' or not
two-sided method, either 'central' or 'square'
logical, do E+M ordering of Lloyd (2008)?
logical, do tie break method? Only allowed when tsmethod!='square'.
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.