power.calc: Generate the power to detect the difference between two...

View source: R/power.calc.R

power.calcR Documentation

Generate the power to detect the difference between two groups

Description

generates a value for the power between two groups

Usage

  power.calc( n, ratio=1, N = 500, test.type, sig.level = 0.05,
    vitdcurves.placebo = NULL, vitdcurves.treatment = NULL,
  	baseline = 0.03, RR = 3, rate = 1, intensity.func = intensity.function(), 
  	holding.time = 2, lohi.vit = c(10,70), clt = NULL, mc.error = 1, boot.rep = 9999, 
  	parallel = FALSE, num.cores = NULL, verbose=FALSE )

Arguments

n

Numeric, the number of participants in the control group.

ratio

Ratio greater than or equal to 1 giving size of treatment group as a multiple of n. Defaults to groups of equal size.

N

Number of simulations of the study to run.

test.type

Type of test to calculate the power, one of "count" or "proportions".

sig.level

Significance level used to test for a statistically significant difference between the groups.

vitdcurves.placebo

An object of class vitd.curve.

vitdcurves.treatment

An object of class vitd.curve.

baseline

Baseline prevalence of getting diseased at any exposure time. Probability of getting diseased when a participant has sufficient vitamin D levels.

RR

Fold risk difference between getting infection between the most deficient and most sufficient vitamin D levels.

rate

Expected number of exposures per week, the rate at which exposures occur in the equivalent homogeneous Poisson process.

intensity.func

Function taking time as sole argument and returns value between 0 and 1, input to nhpp function see poisson package.

holding.time

Expected number of weeks for the holding time.

lohi.vit

Inflection points of the relative risk curve used in infection.count.

clt

Logical or vector of logical values of same length as n indicating whether to use Central Limit Theorem approximation for the test when TRUE. Default is NULL and determination is automatic based on whether group size is less than 35 or not.

mc.error

Number of times to repeat the experiment at each n value to explore Monte Carlo error.

boot.rep

Number of bootstrap samples to carry out non-parametric tests of hypotheses.

parallel

Use parallel processing to carry out the simulations. This will parallelise over mc.error.

num.cores

Number of cores to exploit in parallel mode. Defaults to (cores available) - 1.

verbose

If TRUE print out regular updates on progression. Not available when parallel is set to TRUE.

Value

power.calc returns an object of class power.calc that is a list. The list has the following slots.

test.type

The type of study the power has been calculated on.

baseline

The baseline prevalence for disease.

RR

The relative risk of the study.

npergroup

The number of participants per group in the study.

mc.error

Number of repetitions of experiment to approximate Monte Carlo error.

power

A length(RR) x mc.error x length(npergroup) array of estimated power values.

eff.size

A length(RR) x mc.error x length(npergroup) array of estimated treatment effects (differences between groups).

Author(s)

Rebecca Mangan and Jason Wyse

Examples

# simulate placebo group
placebo <- vitd.curve( n = 10, type = "placebo" )

# simulate treatment group
treatment <- vitd.curve( n = 10, type = "dynamic-dose" )

# intensity function for exposures to infection
intensfun <- intensity.function( summer.rate = 0, winter.rate = 1 )
  
# calculate power: example only- run for much larger value of N
pow <- power.calc( n = c(10,20,30), 
        N = 10,  test.type = 'count', 
        vitdcurves.placebo = placebo, vitdcurves.treatment = treatment,
        baseline = 0.03, RR = c(2,4), rate = 1, intensity.func = intensfun, boot.rep=2000 )
            
### NOT RUN ###            
# approximate the Monte Carlo error in estimation of the power-- takes longer to run
#pow <- power.calc( n = c(10,20,30), 
#         N = 100, test.type = 'count', 
#         vitdcurves.placebo = placebo, vitdcurves.treatment = treatment,
#         baseline = 0.03, RR = c(2,3,4), rate = 1, 
#         intensity.func = intensfun, mc.error = 10 )

# plot power curves
plot( pow, xlab = "n", x.legend = 10, y.legend = 1, main.legend = "Relative Risk" )

SimVitD documentation built on Aug. 20, 2023, 5:06 p.m.