Skip to contents

generateDenominatorCohortSet() creates a set of cohorts that can be used for the denominator population in analyses of incidence, using estimateIncidence(), or prevalence, using estimatePointPrevalence() or estimatePeriodPrevalence().

Usage

generateDenominatorCohortSet(
  cdm,
  name,
  cohortDateRange = as.Date(c(NA, NA)),
  ageGroup = list(c(0, 150)),
  sex = "Both",
  daysPriorObservation = 0,
  requirementInteractions = TRUE
)

Arguments

cdm

A CDM reference object

name

Name of the cohort table to be created. Note if a table already exists with this name in the database (give the prefix being used for the cdm reference) it will be overwritten.

cohortDateRange

Two dates. The first indicating the earliest cohort start date and the second indicating the latest possible cohort end date. If NULL or the first date is set as missing, the earliest observation_start_date in the observation_period table will be used for the former. If NULL or the second date is set as missing, the latest observation_end_date in the observation_period table will be used for the latter.

ageGroup

A list of age groups for which cohorts will be generated. A value of list(c(0,17), c(18,30)) would, for example, lead to the creation of cohorts for those aged from 0 to 17, and from 18 to 30. In this example an individual turning 18 during the time period would appear in both cohorts (leaving the first cohort the day before their 18th birthday and entering the second from the day of their 18th birthday).

sex

Sex of the cohorts. This can be one or more of: "Male", "Female", or "Both".

daysPriorObservation

The number of days of prior observation observed in the database required for an individual to start contributing time in a cohort.

requirementInteractions

If TRUE, cohorts will be created for all combinations of ageGroup, sex, and daysPriorObservation. If FALSE, only the first value specified for the other factors will be used. Consequently, order of values matters when requirementInteractions is FALSE.

Value

A cdm reference

Examples

# \donttest{
cdm <- mockIncidencePrevalenceRef(sampleSize = 1000)
cdm <- generateDenominatorCohortSet(
  cdm = cdm,
  name = "denominator",
  cohortDateRange = as.Date(c("2008-01-01", "2020-01-01"))
)
#>  Creating denominator cohorts
#>  Cohorts created in 0 min and 2 sec
cdm
#> 
#> ── # OMOP CDM reference (duckdb) of mock ───────────────────────────────────────
#>omop tables: person, observation_period
#>cohort tables: target, outcome, denominator
#>achilles tables: -
#>other tables: -
# }