SELF-CONTROLLED CASE SERIES STUDIES
  • Home
  • R
  • STATA
  • SAS
  • About us

Using R for self-controlled case series studies

R package SCCS
An R package, SCCS, to fit self-controlled case series models and extensions was written by Yonas Ghebremichael-Weldesselassie. This can fit:
  • The standard SCCS model.
  • The semiparametric SCCS model. (Farrington CP and Whitaker HJ. Semi-parametric analysis of case series data. JRSS C, 2006, 55(5): 553-594.)
  • The SCCS model for event dependent observation periods. (Farrington CP et al. Self-Controlled Case Series Analysis with Event-Dependent Observation Periods. JASA, 2011, 106(494): 417–426.)
  • The SCCS model for event dependent exposures or the pseudolikelihood method (Farrington CP, Whitaker HJ and Hocine MN. Case series analysis for censored, perturbed or curtailed post-event exposures. Biostatistics, 2009, 10(1): 3-16.)
  • The SCCS model with smooth (spline-based) age effect. (Weldeselassie YG, Whitaker HJ and Farrington CP. Self-Controlled Case Series Method with Smooth Age Effect. Statistics in Medicine, 2014, 33(4): 639-649. DOI: 10.1002/sim.5949)
  • The SCCS model with smooth (spline-based) exposure effect, for a single exposure. (Ghebremichael-Weldeselassie Y, Whitaker HJ, Farrington CP. Flexible modelling of vaccine effect in self-controlled case series models. Biometrical journal, 2016, 58(3): 607-622.)
  • The full spline based SCCS model, for a single smoothed exposure and age effect together. (Ghebremichael-Weldeselassie Y, Whitaker HJ and Farrington CP. Spline-based self-controlled case series method. Statistics in Medicine, 2017, 36: 3022–3038. DOI: 10.1002/sim.7311)
It also includes the three data sets used in the tutorial paper, new data sets for our book 'Self-controlled case series studies: a modelling guide with R', a sample size calculator, a function for simulating data suitable for SCCS analyses and a function to reformat the data, ready to fit the model using clogit.
SCCS package on CRAN
Version 1.1, 13/05/2019. Fixed glitch in data sorting, new version available via link at top and should appear on CRAN soon.

Data sets and R files
All data sets used in the book 'Self-controlled case series studies: a modelling guide with R' can be downloaded as text files below (so can be imported into other software). The script files to run the analyses in R are also given.
  • midat.txt    midat.r
  • siddat.txt    siddat.r
  • rotdat.txt    rotdat.r
  • bupdat.txt    bupdat.r
  • opvdat.txt    opvdat.r
  • nrtdat.txt    nrtdat.r
  • rsvdat.txt    rsvdat.r
  • pmdat.txt    pmdat.r
  • bpdat.txt    bpdat.r
  • febdat.txt    febdat.r
  • amdat.txt    amdat.r
  • apdat.txt    apdat.r
  • condat.txt    condat.r
  • itpdat.txt    itpdat.r
  • intdat.txt    intdat.r
  • gbsdat.txt    gbsdat.r
  • autdat.txt    autdat.r
  • adidat.txt    adidat.r
  • hibdat.txt    hibdat.r
  • addat.txt    addat.r
  • dtpdat.txt    dtpdat.r
  • gidat.txt    gidat.r
  • hipdat.txt    hipdat.r

Simple examples for the Statistics in Medicine tutorial paper
MMR and meningitis in Oxford example
To run the MMR and meningitis in Oxford example detailed in the tutorial paper save these two files:
ox.txt, the data in a tab-delimited text file.
oxford.r, the commands in an r script file.
Open oxford.r and select run all under the edit menu.
ITP and MMR example
itp.r fits the multiple risk periods example on p.1782-1783 of the tutorial paper.
itp.txt, data
itp.r, r script file
Intussusception and oral polio vaccine example
intuss.r fits analysis 5, repeat exposures example detailed on p.1787-1789 of the tutorial paper.
intuss.txt, data
intuss.r, r script file ​

R packages to fit conditional generalised linear models
There are three ways in which we can fit GLMs equivalent to the product multinomial SCCS likelihood after the data have been reformatted:
  1. Download the gnm package and use gnm to fit a conditional Poisson regression model with eliminate = indiv (where indiv is a factor for each individual in the data set)
  2. Use the survival package (included in R's recommended packages) and use clogit to fit a logistic regression model with strata = event (where event is a factor for each event in the data set, rather than a factor for each individual). Here, we fit a conditional logistic regression model rather than a conditional Poisson regression model: because recurrent events are assumed to be independent the conditional logistic likelihood is equivalent if each event is treated like a separate individual.
  3. Use the cyclops package. This is used by OHDSI (see below).
All examples on this webpage and our R package SCCS use clogit, therefore reformatted data to fit SCCS models looks a little different than for other software.

OMOP/OHDSI R package
An R package, SelfControlledCaseSeries, for performing Self-Controlled Case Series (SCCS) analyses in observational databases converted to the OMOP Common Data Model, was created by Martijn Schuemie; available from the link below.
https://github.com/OHDSI/SelfControlledCaseSeries

Site powered by Weebly. Managed by Easy Internet Solutions LTD
  • Home
  • R
  • STATA
  • SAS
  • About us