Skip to content

Commit

Permalink
Update 03_age_sex_matching
Browse files Browse the repository at this point in the history
  • Loading branch information
Marta Alcalde-Herraiz committed Jan 8, 2024
1 parent eb76cf9 commit 67c0b0f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions vignettes/a03_age_sex_matching.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CohortConstructor packages includes a function to obtain an age and sex matched
## Create mock data
We will first use `mockDrugUtilisation()` functin from DrugUtilisation package to create mock data.

```{r setup}
```{r, include = FALSE}
library(CohortConstructor)
library(dplyr)
library(DrugUtilisation)
Expand All @@ -30,15 +30,15 @@ cdm <- mockDrugUtilisation(numberIndividual = 200)

As we will use `cohort1` to explore `generateMatchedCohortSet()`, let us first use `cohort_attrition()` from CDMConnector package to explore the this cohort:

```{r setup}
```{r, include = FALSE}
CDMConnector::cohort_set(cdm$cohort1)
```
Notice that there are three cohorts within this tibble, with id's going from 1 to 3.

# Use `generateMatchedCohortSet()` to create an age-sex matched cohort
Let us first see an example of how this function works. For its usage, we need to provide a `cdm` object, the `targetCohortName`, which is the name of the table containing the cohort of interest, and the `name` of the new table that will be created containing the cohort and the matching cohort. We will also use the argument `targetCohortId` to specify that we only want a matching cohort for `cohort_definition_id = 1`.

```{r setup}
```{r, include = FALSE}
cdm <- generateMatchedCohortSet(cdm = cdm,
name = "matched_cohort1",
targetCohortName = "cohort1",
Expand All @@ -54,11 +54,11 @@ Notice that in the generated tibble, there are two cohorts: `cohort_definition_i

The default matching ratio is 1:1. Use `cohort_counts()` from CDMConnector to check if the matching has been done as desired.

```{r setup}
```{r, include = FALSE}
CDMConnector::cohort_count(cdm$matched_cohort1)
```
To have more information about the exclusion criteria applied to perform the matching, use `cohort_attrition()` from CDMConnector package:
```{r setup}
```{r, include = FALSE}
# Original cohort
CDMConnector::cohort_attrition(cdm$matched_cohort1) %>% filter(cohort_definition_id == 1)
Expand All @@ -69,7 +69,7 @@ Briefly, from the original cohort, we exclude first those individuals that do no

You can modify the `ratio` parameter to tailor your matched cohort.

```{r setup}
```{r, include = FALSE}
cdm <- generateMatchedCohortSet(cdm = cdm,
name = "matched_cohort1",
targetCohortName = "cohort1",
Expand Down

0 comments on commit 67c0b0f

Please sign in to comment.