Function for estimating the sample size needed to have a pre-specified power for the one-sided non-inferiority t-test for normal or log-normal distributed data.
sampleN.noninf(alpha = 0.025, targetpower = 0.8, logscale = TRUE,
margin,theta0, CV, design = "2x2", robust = FALSE,
details = FALSE, print = TRUE, imax=100)
A data.frame with the input settings and results will be returned.
Explore it with str(sampleN.noninf(...)
Significance level (one-sided). Defaults here to 0.025.
Power to achieve at least. Must be >0 and <1.
Typical values are 0.8 or 0.9.
Should the data used on log-transformed or on original scale? TRUE
(default) or FALSE
.
‘True’ or assumed T/R ratio or difference.
In case of logscale=TRUE
it must be given as ratio T/R.
If logscale=FALSE
, the difference in means. In this case, the difference may be expressed in two ways: relative to the same (underlying) reference mean, i.e. as (T-R)/R = T/R - 1; or as difference in means T-R. Note that in the former case the units of margin
and CV
need also be given relative to the reference mean (specified as ratio).
Defaults to 0.95 if logscale=TRUE
or to -0.05 if logscale=FALSE
Non-inferiority margin.
In case of logscale=TRUE
it is given as ratio.
If logscale=FALSE
, the limit may be expressed in two ways:
difference of means relative to the same (underlying) reference mean or in units of the difference of means.
Note that in the former case the units of CV
and theta0
need also be given relative to the reference mean (specified as ratio).
Defaults to 0.8 if logscale=TRUE
or to -0.2 if logscale=FALSE
.
In case of logscale=TRUE
the (geometric) coefficient of variation given as ratio.
If logscale=FALSE
the argument refers to (residual) standard deviation of the response. In this case, standard deviation may be expressed two ways: relative to a reference mean (specified as ratio sigma/muR), i.e. again as a coefficient of variation; or untransformed, i.e. as standard deviation of the response. Note that in the former case the units of theta0
, theta1
and theta2
need also be given relative to the reference mean (specified as ratio).
In case of cross-over studies this is the within-subject CV, in case of a parallel-group design the CV of the total variability.
Character string describing the study design.
See known.designs
for designs covered in this package.
Defaults to FALSE. With that value the usual degrees of freedom will be used.
Set to TRUE
will use the degrees of freedom according to the ‘robust’ evaluation
(aka Senn’s basic estimator). These df are calculated as n-seq
.
See known.designs()$df2
for designs covered in this package.
Has only effect for higher-order crossover designs.
If TRUE
the design characteristics and the steps during
sample size calculations will be shown.
Defaults to FALSE
.
If TRUE
(default) the function prints its results.
If FALSE
only the data.frame with the results will be returned.
Maximum number of steps in sample size search.
Defaults to 100. Adaption only in rare cases needed.
The function does not vectorize properly.
If you need sample sizes with varying CVs, use f.i. for-loops or the apply-family.
D. Labes
The sample size is calculated via iterative evaluation of power.noninf()
.
Start value for the sample size search is taken from a large sample approximation.
The sample size is bound to 4 as minimum.
The estimated sample size gives always the total number of subjects (not subject/sequence in crossovers or subjects/group in parallel designs -- like in some other software packages).
Notes on the underlying hypotheses
If the supplied margin is < 0 (logscale=FALSE
) or < 1 (logscale=TRUE
),
then it is assumed higher response values are better. The hypotheses are
H0: theta0 <= margin vs. H1: theta0 > margin
,
where theta0 = mean(test)-mean(reference)
if logscale=FALSE
or
H0: log(theta0) <= log(margin) vs. H1: log(theta0) > log(margin)
,
where theta0 = mean(test)/mean(reference)
if logscale=TRUE
.
If the supplied margin is > 0 (logscale=FALSE
) or > 1 (logscale=TRUE
),
then it is assumed lower response values are better. The hypotheses are
H0: theta0 >= margin vs. H1: theta0 < margin
where theta0 = mean(test)-mean(reference)
if logscale=FALSE
or
H0: log(theta0) >= log(margin) vs. H1: log(theta0) < log(margin)
where theta0 = mean(test)/mean(reference)
if logscale=TRUE
.
This latter case may also be considered as ‘non-superiority’.
Julious SA. Sample sizes for clinical trials with Normal data. Stat Med. 2004;23(12):1921--86. tools:::Rd_expr_doi("10.1002/sim.1783")
known.designs
, power.noninf
# using all the defaults: margin=0.8, theta0=0.95, alpha=0.025
# log-transformed, design="2x2"
sampleN.noninf(CV = 0.3)
# should give n=48
#
# 'non-superiority' case, log-transformed data
# with assumed 'true' ratio somewhat above 1
sampleN.noninf(CV = 0.3, targetpower = 0.9,
margin = 1.25, theta0 = 1.05)
# should give n=62
Run the code above in your browser using DataLab