samplesize: Sample size calculation in SCCS

View source: R/samplesize.R

samplesizeR Documentation

Sample size calculation in SCCS


The function calculates the sample size required for an SCCS analysis.


samplesize(eexpo, risk, astart, aend, p, alpha=0.05, power=0.8, eage=NULL,



the design value of the exposure related relative incidence.


a positive number showing the duration the risk period. It should not be greater than the duration of the shortest age group, if age groups are specified.


age at start of the observation period. It is an integer greater or equal to 0, that is the same start of observation for all cases.


age at end of an observation period. It is an integer greater than 0, that is the same end of observation for all cases.


a vector/scalar of proportions of exposed in each age group, the default is p=1 where there are no age effects and all cases are exposed.


level of significance e.g 0.05.


the power required to detect the relative incidence specified in eexpo, e.g 0.8.


age related relative incidence parameters, the reference group is the first one.


a vector of cut points of the age groups where each value represents the start of an age category. The first element in the vector is the start of the second age group. The first age group starts at the minimum of astart, the start of observation period. The default is NULL (i.e no age effects included).


a sample size is produced.


Yonas Ghebremichael-Weldeselassie, Heather Whitaker, Paddy Farrington.


Musonda, P., Farrington, C. P., and Whitaker, H. (2006). Sample sizes for self-controlled case series studies. Statistics in Medicine 25, 2618–2631.

Farrington P., Whitaker H., and Ghebremichael-Weldeselassie Y. (2018). Self-controlled Case Series Studies: A modelling Guide with R. Boca Raton: Chapman & Hall/CRC Press.


# Sample size for exposure RI = 2.5 with 21 days risk period, 
# all cases exposed. The level of significance is 0.05 
# with 80% power. The sample size of when p=1 is: 

   ss1 <- samplesize(eexpo=2.5, risk=21, astart=366, aend=730,
                 p=1, alpha=0.05, power=0.8)


# the sample size of events from cases exposed or not when 75% of the 
# population are exposed

   ss2 <- samplesize(eexpo=2.5, risk=21, astart=366, aend=730,
                 p=0.75, alpha=0.05, power=0.8)


# Sample size when age effect is included and the proportions of the  
# target exposed population which are exposed in each age group
# are p=c(0.50,0.35,0.1,0.05): 

   ss3 <- samplesize(eexpo=2.5, risk=21, astart=366, aend=730,
                 p=c(0.50,0.35,0.1,0.05), alpha=0.05, power=0.8,
                 eage=c(1.2,1.6,2.0), agegrp=c(457,548,639))

# Suppose that the sample is from the entire population with 75% exposed,
# then p=0.75*c(0.50,0.35,0.1,0.05)  

  ss4 <- samplesize(eexpo=2.5, risk=21, astart=366, aend=730,
                 p=0.75*c(0.50,0.35,0.1,0.05), alpha=0.05, power=0.8,
                 eage=c(1.2,1.6,2.0), agegrp=c(457,548,639)) 

SCCS documentation built on July 5, 2022, 5:05 p.m.