Estimate the sample size that would be required to detect a specified difference in a paired difference data study. The estimate is based on the variability that was observed in a previous paired difference data study. A cgPairedDifferenceSampleSizeTable class object is created.
1 2 3  ## S4 method for signature 'cgPairedDifferenceFit'
samplesizeTable(fit, direction, mmdvec,
power = 0.80, alpha = 0.05, nmax = 1000, display = "print", ...)

fit 
A 
direction 
A 
mmdvec 
A 
power 
The power for the future study, set by default to be 
alpha 
The significance level or alpha for the future study, set by default
as 
nmax 
The maximum number of subjects per group. If more subjects are estimated to be required, than the exact number required is not reported, only the fact that more than the maximum number would be required. This is in place to prevent long and likely unnecessary calculations. 
display 
One of three valid values:

... 
Additional arguments. Only one is currently valid:

Here, the estimated sample size actually refers to the number of experimental units. Hence the number of observations will always be twice the number of experimental units, due to the paired structure.
This sample size method only works for the classical least squares fitted model, since there is no analogous decomposition of total variance into betweenexperimental unit and withinexperimental unit variance components. Sample sizes are estimated for detecting a minimum difference with the classical least squares ttest / Ftest.
The correction = "df"
argument specifies a method that Fleiss
(1986, pages 129130) attributes to Cochran and Cox (1957) and Fisher.
The correction decreases the relative efficiency that is calculated
from accounting for correlated paired observations, relative to the unpaired two group
design. The adjustment accounts for the different degrees of freedom
used for the variance components in the paired design
(betweenexperimental unit, withinexperimettal unit, total variability.)
Since the correction reduces the relative efficiency, and the
noncentrality parameter is also reduced. The correction
is a multiplicative factor bounded below
by 0.833 and approaches 1 as the number of experimental units
increments from the minimum of n=2
. The reduction in the
noncentrality parameter increases the computed sample size.
Creates an object of class cgPairedDifferenceSampleSizeTable
, with the
following slots:
ols.sstable
A matrix with the estimated experimental
unit sample sizes based on the
classical model variance estimates. The matrix has 3 columns and
one row for each element of the mmdvec
vector
.
The first column specifies the minimum meaningful difference ("mmd"
).
The second column gives the number of experimental units
("n"
) required,
possibly truncated at nmax
.
The third column gives the total number of
observations ("N"
), also possibly truncated at
nmax
. Since this for the paired groups design, N = n
* 2
will always hold.
settings
A list of properties mostly carried asis from the
data
argument object of class
cgPairedDifferenceData
, with the following additional members:
sigmaest
A list with 1 member, ols
, containing the
estimated spread (sigma, standard deviation) variance
estimates from
the classical model of fit
. This list component is a
vector of length 3, providing the withinexperimental unit,
between experimental unit, and total variability estimates.
planningname
A character
describing the study
or purpose of the sample size analysis. Taken from the
settings$analysisname
of the fit
object.
direction
A saved copy of the direction
argument.
alpha
A saved copy of the alpha
argument.
power
A saved copy of the power
argument.
nmax
A saved copy of the nmax
argument.
Contact cg@billpikounis.net for bug reports, questions, concerns, and comments.
Bill Pikounis, John Oleynick, and Eva Ye
Fleiss, J. L. (1986). The Design and Analysis of Clinical Experiments, pages 129  130. New York: Wiley.
Cochran, W. G. and Cox, G. M. (1957), Experimental Designs. Second edition. Wiley.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  data(anorexiaFT)
anorexiaFT.data < prepareCGPairedDifferenceData(anorexiaFT, format="groupcolumns",
analysisname="Anorexia FT",
endptname="Weight",
endptunits="lbs",
expunitname="Patient",
digits=1,
logscale=TRUE)
anorexiaFT.fit < fit(anorexiaFT.data)
## Recall the interest is in increased weight for the anorexia FT
## (family treatment) group of patients
samplesizeTable(anorexiaFT.fit, direction="increasing",
mmdvec=c(5, 10, 15, 20))
## and with the adjustment on the noncentrality parameter
samplesizeTable(anorexiaFT.fit, direction="increasing",
mmdvec=c(5, 10, 15, 20), correction="df")

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.