Skip to contents

phenotypeR diagnostics on the cohort of input with relation to a denomination population. Diagnostics include:

* Incidence * Prevalence

Usage

populationDiagnostics(
  cohort,
  populationSample = 1e+06,
  populationDateRange = as.Date(c(NA, NA))
)

Arguments

cohort

Cohort table in a cdm reference

populationSample

Number of people from the cdm to sample. If NULL no sampling will be performed

populationDateRange

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.

Value

A summarised result

Examples

# \donttest{
library(PhenotypeR)
library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union

cdm <- mockPhenotypeR()

dateStart <- cdm$my_cohort |>
  summarise(start = min(cohort_start_date, na.rm = TRUE)) |>
  pull("start")
dateEnd   <- cdm$my_cohort |>
  summarise(start = max(cohort_start_date, na.rm = TRUE)) |>
  pull("start")

result <- cdm$my_cohort |>
  populationDiagnostics(populationDateRange = c(dateStart, dateEnd))
#>  Creating denominator for incidence and prevalence
#>  Sampling person table to 1e+06
#>  Creating denominator cohorts
#> ! cohort columns will be reordered to match the expected order:
#>   cohort_definition_id, subject_id, cohort_start_date, and cohort_end_date.
#>  Cohorts created in 0 min and 6 sec
#>  Estimating incidence
#>  Getting incidence for analysis 1 of 12
#>  Getting incidence for analysis 2 of 12
#>  Getting incidence for analysis 3 of 12
#>  Getting incidence for analysis 4 of 12
#>  Getting incidence for analysis 5 of 12
#>  Getting incidence for analysis 6 of 12
#>  Getting incidence for analysis 7 of 12
#>  Getting incidence for analysis 8 of 12
#>  Getting incidence for analysis 9 of 12
#>  Getting incidence for analysis 10 of 12
#>  Getting incidence for analysis 11 of 12
#>  Getting incidence for analysis 12 of 12
#>  Overall time taken: 0 mins and 13 secs
#>  Estimating prevalence
#>  Getting prevalence for analysis 1 of 12
#>  Getting prevalence for analysis 2 of 12
#>  Getting prevalence for analysis 3 of 12
#>  Getting prevalence for analysis 4 of 12
#>  Getting prevalence for analysis 5 of 12
#>  Getting prevalence for analysis 6 of 12
#>  Getting prevalence for analysis 7 of 12
#>  Getting prevalence for analysis 8 of 12
#>  Getting prevalence for analysis 9 of 12
#>  Getting prevalence for analysis 10 of 12
#>  Getting prevalence for analysis 11 of 12
#>  Getting prevalence for analysis 12 of 12
#>  Time taken: 0 mins and 7 secs

CDMConnector::cdmDisconnect(cdm = cdm)
# }