View source: R/simulatesccsdata.R

simulatesccsdata | R Documentation |

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)

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

`astart` |
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 |

`aend` |
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. |

`adrug` |
a vector (of length |

`aedrug` |
a vector of ages at which exposure-related risk ends or a matrix if there are multiple exposures. The number of columns of |

`expogrp` |
a vectors of days to the start of exposure-related risk, counted from |

`eexpo` |
a vector of exposure-related relative incidences. |

`washout` |
a vector of days to start of washout periods counted from |

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

`agegrp` |
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 |

`eage` |
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 |

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 set.seed(4321) 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) simdata

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.