# 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" )
Run the code above in your browser using DataLab