Skip to contents

This comprises all the diagnostics that are being offered in this package, this includes:

* A diagnostics on the database via `databaseDiagnostics`. * A diagnostics on the cohort_codelist attribute of the cohort via `codelistDiagnostics`. * A diagnostics on the cohort via `cohortDiagnostics`. * A diagnostics on the population via `populationDiagnostics`. * A diagnostics on the matched cohort via `matchedDiagnostics`.

Usage

phenotypeDiagnostics(
  cohort,
  databaseDiagnostics = TRUE,
  codelistDiagnostics = TRUE,
  cohortDiagnostics = TRUE,
  populationDiagnostics = TRUE,
  populationSample = 1e+06,
  populationDateRange = as.Date(c(NA, NA)),
  matchedDiagnostics = TRUE,
  matchedSample = 1000
)

Arguments

cohort

Cohort table in a cdm reference

databaseDiagnostics

If TRUE, database diagnostics will be run.

codelistDiagnostics

If TRUE, codelist diagnostics will be run.

cohortDiagnostics

If TRUE, cohort diagnostics will be run.

populationDiagnostics

If TRUE, population diagnostics will be run.

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.

matchedDiagnostics

If TRUE, cohort to population diagnostics will be run.

matchedSample

The number of people to take a random sample for matching. If NULL, no sampling will be performed.

Value

A summarised result

Examples

# \donttest{
library(PhenotypeR)

cdm <- mockPhenotypeR()

result <- phenotypeDiagnostics(cdm$my_cohort)
#> 
#> 
#> Warning: ! cohort_codelist attribute for cohort not found
#>  Returning an empty summarised result
#>  You can add a codelist to a cohort with `addCodelistAttribute()`.
#> 
#>  Getting cohort attrition
#>  Getting cohort overlap
#>  Getting cohort timing
#>  The following estimates will be computed:
#>  days_between_cohort_entries: median, q25, q75, min, max, density
#> ! Table is collected to memory as not all requested estimates are supported on
#>   the database side
#> → Start summary of data, at 2025-02-19 09:31:06.49217
#>  Summary finished, at 2025-02-19 09:31:06.578989
#>  cohort_1 - get cohort and index
#>  cohort_1 - cohort summary
#>  adding demographics columns
#>  adding tableIntersectCount 1/1
#>  summarising data
#>  summariseCharacteristics finished!
#>  cohort_1 - age density
#>  The following estimates will be computed:
#>  age: density
#> → Start summary of data, at 2025-02-19 09:31:10.730183
#>  Summary finished, at 2025-02-19 09:31:11.032824
#>  cohort_2 - get cohort and index
#>  cohort_2 - cohort summary
#>  adding demographics columns
#>  adding tableIntersectCount 1/1
#>  summarising data
#>  summariseCharacteristics finished!
#>  cohort_2 - age density
#>  The following estimates will be computed:
#>  age: density
#> → Start summary of data, at 2025-02-19 09:31:15.10905
#>  Summary finished, at 2025-02-19 09:31:15.41638
#> 
#>  Creating denominator for incidence and prevalence
#>  Sampling person table to 1e+06
#>  Creating denominator cohorts
#>  Cohorts created in 0 min and 5 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 12 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
#> 
#>  Sampling cohorts
#> Returning entry cohort as the size of the cohorts to be sampled is equal or
#> smaller than `n`.
#>  Generating an age and sex matched cohort for cohort_1
#> Starting matching
#>  Creating copy of target cohort.
#>  1 cohort to be matched.
#>  Creating controls cohorts.
#>  Excluding cases from controls
#>  Matching by gender_concept_id and year_of_birth
#>  Removing controls that were not in observation at index date
#>  Excluding target records whose pair is not in observation
#>  Adjusting ratio
#> Binding cohorts
#>  Done
#>  adding demographics columns
#>  adding tableIntersectCount 1/1
#>  summarising data
#>  summariseCharacteristics finished!
#>  Getting age density
#>  The following estimates will be computed:
#>  age: density
#> → Start summary of data, at 2025-02-19 09:31:53.637289
#>  Summary finished, at 2025-02-19 09:31:53.962827
#>  Running large scale characterisation
#>  Summarising large scale characteristics 
#> 
#>  - getting characteristics from table condition_occurrence (1 of 6)
#>  - getting characteristics from table visit_occurrence (2 of 6)
#>  - getting characteristics from table measurement (3 of 6)
#>  - getting characteristics from table procedure_occurrence (4 of 6)
#>  - getting characteristics from table observation (5 of 6)
#>  - getting characteristics from table drug_exposure (6 of 6)
#>  Sampling cohorts
#> Returning entry cohort as the size of the cohorts to be sampled is equal or
#> smaller than `n`.
#>  Generating an age and sex matched cohort for cohort_2
#> Starting matching
#>  Creating copy of target cohort.
#>  1 cohort to be matched.
#>  Creating controls cohorts.
#>  Excluding cases from controls
#>  Matching by gender_concept_id and year_of_birth
#>  Removing controls that were not in observation at index date
#>  Excluding target records whose pair is not in observation
#>  Adjusting ratio
#> Binding cohorts
#>  Done
#>  adding demographics columns
#>  adding tableIntersectCount 1/1
#>  summarising data
#>  summariseCharacteristics finished!
#>  Getting age density
#>  The following estimates will be computed:
#>  age: density
#> → Start summary of data, at 2025-02-19 09:32:45.828621
#>  Summary finished, at 2025-02-19 09:32:46.150672
#>  Running large scale characterisation
#>  Summarising large scale characteristics 
#> 
#>  - getting characteristics from table condition_occurrence (1 of 6)
#>  - getting characteristics from table visit_occurrence (2 of 6)
#>  - getting characteristics from table measurement (3 of 6)
#>  - getting characteristics from table procedure_occurrence (4 of 6)
#>  - getting characteristics from table observation (5 of 6)
#>  - getting characteristics from table drug_exposure (6 of 6)
#> 

CDMConnector::cdmDisconnect(cdm = cdm)
# }