Estimate the sample size that would be required to detect a specified difference in a one factor study. The estimate is based on the variability that was observed in a previous one factor study. A cgOneFactorSampleSizeTable class object is created.
# S4 method for cgOneFactorFit
samplesizeTable(fit, direction, mmdvec,
power = 0.80, alpha = 0.05, nmax = 1000, display = "print", ...)Creates an object of class cgOneFactorSampleSizeTable, with the
following slots:
ols.sstableA matrix with the estimated sample sizes based on the
classical model variance estimates, or NULL. 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 subjects required for each
group ("n"), possibly truncated at nmax.
The third column gives the total number of
subjects required ("N"), also truncated if
nmax is truncated.
rr.sstableA matrix with the estimated sample sizes based on the
robust model variance estimates, or else NULL if
model="olsonly" was specified. See the ols.sstable
slot description above for the analogous layout of the matrix.
settingsA list of properties mostly carried as-is from the
data argument object of class
cgOneFactorData, with the following additional members:
sigmaestA list with 2 members, ols, containing the
estimated spread (sigma, standard deviation) from
the classical model of fit,
and rr,
containing the estimated spread (sigma, standard deviation)
from the robust model of
fit, or
NULL if the robust model was not fit.
planningnameA character describing the study
or purpose of the sample size analysis. Taken from the
settings$analysisname of the fit object.
ngrpsA saved copy of the ngrps argument.
directionA saved copy of the direction argument.
alphaA saved copy of the alpha argument.
powerA saved copy of the power argument.
nmaxA saved copy of the nmax argument.
A cgOneFactorFit object from a previous one factor study.
A character value indicating whether the sample size should be estimated
to detect an "increase" or a "decrease". This only effects
the sample size estimates if the previous study in fit was
analyzed on the log scale, in which case the differences in mmdvec
are relative differences instead of absolute differences.
For detecting relative changes, the sample size
required to detect a relative increase of 25% is not the same as the sample
size to detect a relative decrease of 25%, for example. But for detecting
absolute changes, the sample size required
to detect an absolute increase of 25 is the same as the sample size
to detect an absolute decrease of 25.
A numeric vector specifying the minimum meaningful differences
to be detected in the future study. If the previous study
in fit was analyzed on the log scale, then the values in mmdvec
are assumed to be relative percentage increases or decreases, depending
on the value of direction. If the previous study in
fit was not analyzed on the log scale, then the values in mmdvec
are assumed to be absolute increases or decreases, depending on
the value of direction. Each value in mmdvec needs to
be positive.
The power for the future study, set by default to be 0.80.
This is equivalent
to \(1 - \beta\), where \(\beta\) is the probability of
committing a Type II error: accepting the null hypothesis of
no difference when differences truly exist.
The significance level or alpha for the future study, set by default
as 0.05.
The maximum number of subjects per group. If more subjects are estimated to be required, then 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.
One of three valid values:
"print"The default value; It calls a print method for the
created cgOneFactorSamplesizeTable object, which is
a formatted text output of the table(s).
"none"Supresses any printing. Useful, for example, when just assignment of the resulting object is desired.
"show"Calls the default showDefault method, which
will just print out the cgOneFactorSamplesizeTable components.
Additional arguments.
ngrps The number of groups that will be in the future one factor
study. The default is ngrps = 2.
modelA character value indicating which variability estimate
in
fit should be
used to estimate the sample size: the robust model ("rronly"),
the classical model ("olsonly"), or both ("both"). If an estimate
is requested for a model that was not fit, then no sample sizes are returned
for that model but an error is not reported (e.g. if only the classical model
was fitted but "both" are requested, only the classical model estimates
will be returned):
"both"Sample Size tables based on both the ordinary
classical least squares and resistant & robust fits are
performed. This is the default when both fits are present in
the cgOneFactorFit object specified in the fit
argument. If the resistant & robust fit is not available,
this value is not relevant.
"olsonly"Only a sample size table based on the ordinary
classical least squares olsfit fit is calculated.
"rronly"Only a sample size table based on the resistant and
robust rrfit fit is calculated.
Bill Pikounis [aut, cre, cph], John Oleynick [aut], Eva Ye [ctb]
This sample size method does not work for fitted models that allowed unequal variances or censored observations.
Sample sizes are estimated for detecting a minimum difference with a global
F test. The algorithm is detailed in Fleiss (1986), Appendix A. When
there are more than 2 groups, the lower bound of possible
noncentrality parameter values is calculated from assuming only two of
the ngrps number of groups differ by the mmdvec/2 amount
from the "grand mean" while the rest of the groups are equal to the grand
mean.
For detecting an absolute difference, the sample size is the
smallest group size n for which
1 - pf (qf (1 - alpha, numdf, dendf), numdf,
dendf, ncp) exceeds power,
where ncp = (n * mmdvec ^ 2) / (2 *
sigamest ^ 2), and sigmaest is the residual mean square error from the model in
fit. For detecting a relative difference, the calculations are
the same except
ncp = (n * (log (sign * mmdvec / 100 + 1) ) ^ 2) / (2
* sigmaest ^ 2), where
sign = -1 if direction="decreasing",
and sign = 1 if direction = "increasing".
Fleiss, J.L. (1986). The Design and Analysis of Clinical Experiments, Appendix A, pages 371 - 376. New York: Wiley.
data(canine)
canine.data <- prepareCGOneFactorData(canine, format="groupcolumns",
analysisname="Canine",
endptname="Prostate Volume",
endptunits=expression(plain(cm)^3),
digits=1, logscale=TRUE, refgrp="CC")
canine.fit <- fit(canine.data)
canine.samplesize <- samplesizeTable(canine.fit, direction="increasing",
mmdvec=c(10, 25, 50, 75, 100))
samplesizeTable(canine.fit, direction="decreasing",
mmdvec=c(25, 50, 75), model="olsonly")
Run the code above in your browser using DataLab