Creating covariates using cohort attributes Martijn J. Schuemie 2016-03-28

Contents 1 Introduction

1

2 Overview

1

2.1

Populating the cohort_attribute and attribute_definition tables . . . . . . . . . . . . . . . .

3 Example

1 2

3.1

Creating the cohort attributes and attributes definitions . . . . . . . . . . . . . . . . . . . . .

2

3.2

Using the attributes as covariates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3

1

Introduction

This vignette assumes you are already familiar with the FeatureExtraction package. The FeatureExtraction package can generate a default set of covariates, such as one covariate for each condition found in the condition_occurrence table. However, for some reasons one might need other covariates than those included in the default set. In the vignette called Creating custom covariate builders a process is described for creating custom covariate builders that create covariates on the fly and can be re-used across studies. In contrast, this vignette describes a process that uses the cohort_attribute table in the common data model, and assumes the user has already populated this table with the requested covariates.

2

Overview

To construct custom covariates, the following steps must be taken: 1. Populate a table with the same structure as the cohort_attribute table in the common data model. 2. Populate a table with the same structure as the attribute_definition table in the common data model. 3. Use the createCohortAttrCovariateSettings function to create a covariateSettings object pointing to the two tables mentioned in the previous steps.

2.1

Populating the cohort_attribute and attribute_definition tables

The cohort_attribute should specify the values of the covariates for every person-cohort_start_date combination in the cohort(s) of interest. It should at least have the following fields: • cohort_definition_id, A key to link to the cohort table. On CDM v4, this field should be called cohort_concept_id. 1

• • • •

‘subject_id’, A key to link to the cohort table. ‘cohort_start_date’, A key to link to the cohort table. ‘attribute_definition_id’, An foreign key linking to the attribute definition table. ‘value_as_number’, A real number.

The first three fields act as a combined key to link the record to an entry in the cohort table. Note that records with zero values can be omitted. The attribute_definition table defines the attributes. It should have at least the following fields: • ‘attribute_definition_id’, A unique identifier of type integer. • ‘attribute_name’, A short description of the attribute. The first field links to the cohort_attribute table, the second field is used as the covariate name.

3 3.1

Example Creating the cohort attributes and attributes definitions

In this example we will create a single covariate: the length of observation prior to the cohort_start_date. We use the following SQL to construct a cohort_attribute table and a attribute_definition table: /*********************************** File LengthOfObsCohortAttr.sql ***********************************/ IF OBJECT_ID('@[email protected]_attribute_table', 'U') IS NOT NULL DROP TABLE @[email protected]_attribute_table; IF OBJECT_ID('@[email protected]_definition_table', 'U') IS NOT NULL DROP TABLE @[email protected]_definition_table; SELECT cohort_definition_id, subject_id, cohort_start_date, 1 AS attribute_definition_id, DATEDIFF(DAY, observation_period_start_date, cohort_start_date) AS value_as_number INTO @[email protected]_attribute_table FROM @[email protected]_table cohort INNER JOIN @cdm_database_schema.observation_period op ON op.person_id = cohort.subject_id WHERE cohort_start_date >= observation_period_start_date AND cohort_start_date <= observation_period_end_date {@cohort_definition_ids != ''} ? { AND cohort_definition_id IN (@cohort_definition_ids) } ; SELECT 1 AS attribute_definition_id, 'Length of observation in days' AS attribute_name INTO @[email protected]_definition_table;

2

We substitute the arguments in this SQL with actual values, translate it to the right SQL dialect, and execute the SQL using SqlRender: library(SqlRender) sql <- readSql("HospitalizationCohorts.sql") sql <- renderSql(sql, cdm_database_schema = cdmDatabaseSchema, cohort_database_schema = cohortDatabaseSchema, cohort_table = "rehospitalization", cohort_attribute_table = "loo_cohort_attr", attribute_definition_table = "loo_attr_def", cohort_definition_ids = c(1,2))$sql sql <- translateSql(sql, targetDialect = connectionDetails$dbms)$sql connection <- connect(connectionDetails) executeSql(connection, sql)

3.2

Using the attributes as covariates

To use the constructed attributes as covariates in a predictive model, we need to create a covariateSettings object: looCovSet <- createCohortAttrCovariateSettings(attrDatabaseSchema = cohortDatabaseSchema, cohortAttrTable = "loo_cohort_attr", attrDefinitionTable = "loo_attr_def", includeAttrIds = c()) We can then use these settings to fetch the covariates object: covariates <- getDbCovariateData(connectionDetails = connectionDetails, cdmDatabaseSchema = cdmDatabaseSchema, cohortDatabaseSchema = resultsDatabaseSchema, cohortTable = "rehospitalization", cohortIds = 1, covariateSettings = looCovSet, cdmVersion = cdmVersion) In this case we will have only one covariate for our predictive model, the length of observation. In most cases, we will want our custom covariates in addition to the default covariates. We can do this by creating a list of covariate settings: covariateSettings <- createCovariateSettings(useCovariateDemographics = TRUE, useCovariateDemographicsGender = TRUE, useCovariateDemographicsRace = TRUE, useCovariateDemographicsEthnicity = TRUE, useCovariateDemographicsAge = TRUE, useCovariateDemographicsYear = TRUE, useCovariateDemographicsMonth = TRUE) looCovSet <- createCohortAttrCovariateSettings(attrDatabaseSchema = cohortDatabaseSchema, cohortAttrTable = "loo_cohort_attr", attrDefinitionTable = "loo_attr_def", includeAttrIds = c()) 3

covariateSettingsList <- list(covariateSettings, looCovSet) covariates <- getDbCovariateData(connectionDetails = connectionDetails, cdmDatabaseSchema = cdmDatabaseSchema, cohortDatabaseSchema = resultsDatabaseSchema, cohortTable = "rehospitalization", cohortIds = 1, covariateSettings = covariateSettingsList, cdmVersion = cdmVersion) In this example both demographic covariates and our length of observation covariate will be generated and can be used in our predictive model.

4

Creating covariates using cohort attributes - GitHub

Mar 28, 2016 - 3.1 Creating the cohort attributes and attributes definitions . ... covariate builders that create covariates on the fly and can be re-used across ...

209KB Sizes 3 Downloads 118 Views

Recommend Documents

Creating signatures for ClamAV - GitHub
Dec 9, 2007 - 2 Debug information from libclamav .... The hash-based signatures shall not be used for text files, HTML and any other .... 10 = PDF files.

Using SqlRender - GitHub
6. 3.5 Case sensitivity in string comparisons . .... would have had no clue the two fields were strings, and would incorrectly leave the plus sign. Another clue that.

Using FeatureExtraction - GitHub
Oct 27, 2017 - Venous thrombosis. 3. 20-24. 2. Medical history: Neoplasms. 25-29. 4. Hematologic neoplasm. 1. 30-34. 6. Malignant lymphoma. 0. 35-39. 7. Malignant neoplasm of anorectum. 0. 40-44. 9. Malignant neoplastic disease. 6. 45-49. 11. Maligna

Instructions for using FALCON - GitHub
Jul 11, 2014 - College of Life and Environmental Sciences, University of Exeter, ... used in FALCON is also available (see FALCON_Manuscript.pdf. ). ... couraged to read the accompanying technical document to learn ... GitHub is an online repository

Attributes-Attitudes.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item.

Species Identification using MALDIquant - GitHub
Jun 8, 2015 - Contents. 1 Foreword. 3. 2 Other vignettes. 3. 3 Setup. 3. 4 Dataset. 4. 5 Analysis. 4 .... [1] "F10". We collect all spots with a sapply call (to loop over all spectra) and ..... similar way as the top 10 features in the example above.

Single studies using the CaseCrossover package - GitHub
Apr 21, 2017 - Loading data on the cases (and potential controls when performing a case-time-control analysis) from the database needed for matching. 2.

image compression using deep autoencoder - GitHub
Deep Autoencoder neural network trains on a large set of images to figure out similarities .... 2.1.3 Representing and generalizing nonlinear structure in data .

Single studies using the CohortMethod package - GitHub
Jun 19, 2017 - We need to tell R how to connect to the server where the data are. ..... work has been dedicated to provide the CohortMethod package.