power.calc | R Documentation |
generates a value for the power between two groups
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 = 500, parallel = FALSE, num.cores = NULL, verbose=FALSE )
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 |
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 |
vitdcurves.treatment |
An object of class |
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 |
clt |
Vector or single logical variable indicating whether Central Limit Theorem should be used to approximate the p-value. |
mc.error |
Number of times to repeat the experiment at each |
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 |
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 |
eff.size |
A |
Rebecca Mangan and Jason Wyse
# 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 num.sims 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,3,4), rate = 1, intensity.func = intensfun ) ### 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" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.