simulatesccsdata: Simulation of SCCS data

View source: R/simulatesccsdata.R

simulatesccsdataR Documentation

Simulation of SCCS data


This function creates a simulated SCCS data set with given design parameters, and can be used to generate cases with observation and risk periods of different durations, multiple risk periods, repeated exposures, and washout periods.


simulatesccsdata(nindivs, astart, aend, adrug, aedrug, expogrp=c(0), eexpo,
                washout=NULL, ewashout=NULL, agegrp=NULL, eage=NULL)



a positive integer: number of cases to be generated (1 event per case).


age at start of an observation period. It is a single number if the same start of observation for all cases is required or a vector of length equal to nindivs to allow different starts of observation periods for different cases.


age at end of the observation period. A single number for the same end of observation periods for all cases or a vector to allow for different end of observation periods.


a vector (of length nindivs) of ages at which exposure starts or a matrix if there are multiple exposures.


a vector of ages at which exposure-related risk ends or a matrix if there are multiple exposures. The number of columns of aedrug is equal to the number of columns of adrug, that is aedrug should be given for each column in adrug.


a vectors of days to the start of exposure-related risk, counted from adrug. E.g if the risk period is [adrug+c,aedrug], use expogrp = c.


a vector of exposure-related relative incidences.


a vector of days to start of washout periods counted from aedrug. The default is NULL, no washout periods.


a vector of true relative incidence values associated with washout periods; it defaults to NULL when washout=NULL.


cut points of age groups, defaults to NULL (i.e no age effect included). These are given as the day of an age category starts, the first age category starts at the minimum of astart.


a vector of age-related relative incidences. The default is NULL where there is no age effect i.e agegrp = NULL. If age-specific relative incidences are from a continuous function eage is a vector of relative incidences at each age and agegrp=NULL.


The true relative incidences related to age and exposure could be generated from discrete or continuous distributions.


A data frame with columns "indiv" = individual identifier, "astart" = age on the day observation period starts, "adrug" = age on the day exposure starts, "aedrug" = age at the end of exposure related risk period, "aend" = age at the end of observation period, and "aevent" = age on the day of outcome event.


Yonas Ghebremichael-Weldeselassie, Heather Whitaker, Paddy Farrington.


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.


# Simulate data where all the cases have same start and end of 
# observation periods and no age effect 


arisk <- round(runif(110,366,730)) # ages at start of exposure

simdata <- simulatesccsdata(nindivs=110, astart=366, aend=730,
                            adrug=arisk, aedrug=arisk+20, eexpo=2.5)


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