mdd.mantelhaen.pow {MDD} | R Documentation |
Computes the true treatment response rates in each stratum closest to the corresponding stratum's control response rate that would be detected with a given power for a two-sample Cochran-Mantel-Haenszel (stratified chi-squared) test with arbitrary number of strata. Optionally, saves data to a file that later can be used to calculate the minimum detectable difference.
mdd.mantelhaen.pow(placebo.size, treat.size, prob.placebo, alpha = 0.05, pow = 0.8, alternative = "two.sided", exact = TRUE, which.strata = "all", size.matrix, to.file = "", from.file = "")
placebo.size |
a vector with the number of subjects in each stratum assigned to the
control group; if omitted, will be derived from size.matrix . |
treat.size |
a vector with the number of subjects in each stratum assigned to the
treatment group; if omitted, will be derived from size.matrix . |
prob.placebo |
a vector of anticipated proportion of responses in each stratum for the control group (but see Details, below). |
alpha |
significance level. |
pow |
power. |
alternative |
indicates the alternative hypothesis and must be one of "two.sided" ,
"greater" , or "less" . You can specify just the initial letter. |
exact |
a logical value indicating whether to do an exact conditional test or use the C-M-H test statistic. |
which.strata |
a list of vectors, each of which is a subset of 1:length(placebo.size) .
These will be the stratum/strata in which the treatment mean will be allowed to differ from the
control mean. |
size.matrix |
a matrix with two columns, the first of which becomes placebo.size
and the second of which becomes treat.size . |
to.file |
the path for the file in which to save the array of responses that are significant for further analysis. |
from.file |
the path for the file containing a response array saved with a previous
mdd.mantelhaen.pow command with to.file given. placebo.size and
treat.size are deduced from the loaded file. |
alternative = "less"
is the alternative that has the treatment group mean
less than the control group mean.
If present, the value of size.matrix
will overwrite both placebo.size
and treat.size
.
prob.placebo
can be specified as a single number, in which case it is assumed that
the response rate in the control group is constant across the strata. In fact, currently the
calculations will use prob.placebo[1]
as the response rate in all control strata.
This may change in a future version of the package.
The default value of which.strata = "all"
translates to all
2^length(placebo.size) - 1
possible non-empty subsets of strata.
The array that is stored in to.file
is called sig.inds
and has the treatment
strata numbers in odd dimensions and the control strata numbers in even dimensions.
Specifically, if placebo.size = c(2,3,4)
and treat.size = c(5,6,7)
, then
dim(sig.inds) = c(6,3,7,4,8,5)
. (Note that the dimensions are one more than the
corresponding sizes because the number of responses in each stratum can be 0
or any
number up to the size of the stratum.) The entries of sig.inds
are 1
for a
significant test, 0
otherwise. In particular, sig.inds[c(1,1,1,1,1,1)]
would
indicate whether or not the test is significant if there were no responses, and
sig.inds[c(4,2,6,1,5,3)]
would indicate the significance of the test with
c(3,5,4)
treatment responses and c(1,0,2)
control responses.
If to.file
does not already end in “.RData
”, that suffix is appended to
to.file
.
The value is a matrix of dimension c(length(which.strata),2)
(if
alternative = "two.sided"
) or c(length(which.strata),1)
, giving the closest
true treatment response rate(s) to prob.placebo[1]
that would be detected as significant
with power pow
at significance level alpha
if the strata corresponding to
which.strata
differed from the control. (See the Examples section for an illustration.)
Can have very long run times when there are three or more strata, or when there are a large number of subjects in all strata combined.
The program that does the actual calculations to determine the significant combinations of
treatment and control responses in each stratum, .mantelhaen
, is flawed, because it
assumes that if a test is significant with fewer control responses than treatment responses, then
either changing a treatment non-responder to a responder or changing a control responder to a
non-responder will maintain significance. This is not, however, true. For example, with
placebo.size = c(3,4,5)
and treat.size = c(8,7,6)
, the p-value for a two-sided test
with c(0,1,0)
control responses and c(0,0,6)
treatment responses is 0.04820937
,
but increasing the treatment responses to c(1,0,6)
changes the p-value to 0.05507853
.
In this particular example, this leads to the program incorrectly identifying 4 tests as not
significant when they are actually significant. Since there are actually 12,364 significant
tests in this example out of a total of 151,200 tests (identified via exhaustive search), the
program's result should be pretty close to the actual answer, and it seems unlikely that this
phenomenon will be a common occurrence in the general case. Nevertheless, the user should be
aware of this illustration of Simpson's paradox. In future versions of the package, this will
hopefully be corrected. (Currently, all the solutions I have thought of will drastically
increase the run time for a very small gain, so I will leave them for future implementation.)
Don Barkauskas (barkda@wald.ucdavis.edu)
See mantelhaen.test
for references.
extract.mdd.mantelhaen
, mdd.mantelhaen
gui.mdd
for a GUI version
sm <- matrix(c(3,4,5,6,7,8), ncol=2) wh <- list(1,c(1,2),c(1,3),c(1,2,3)) mdd.mantelhaen.pow(prob.placebo = 0.25, which.strata = wh, size.matrix = sm) #Takes about 33 seconds in R 2.5.1 on a machine with a Pentium M 1.86GHz #processor and 1 GB RAM. # #If only strata 1 and/or 2 are different from the control, even true treatment #response rates of 0% or 100% in those strata will not be detected with 80% #power. # #If both strata 1 and 3 have true treatment response rates of 0.9578682 or more, #it will be detected with 80% power. # #If all three strata have true treatment response rates of 0.7717062 or more, #it will be detected with 80% power. rm(sm,wh)