OHDSI / FeatureExtraction

An R package for generating features (covariates) for a cohort using data in the Common Data Model.
http://ohdsi.github.io/FeatureExtraction/
61 stars 60 forks source link

Using different endDays for different standard covariate sets #139

Closed lhjohn closed 3 years ago

lhjohn commented 3 years ago

There is only a single parameter endDays, which is used as the end date for all covariates, even the one that are any time prior. Here is the code: Link

I would like to have endDays = 0 for covariates that are assessed any time prior, but endDays = -4 for covariates that are assessed for a long term window.

Is this possible (maybe with a small hack)?

jreps commented 3 years ago

A hack you can currently do is to create two covariate settings, one with any time prior covariates and end days = 0 and another with long term covariates and end days = -4, then combine these by creating a list of these settings: allCovs <- list(covAnyTime, covLongterm).

lhjohn commented 3 years ago

Does this also work with SkeletonPredictionStudy, because when using the code below, the package wont get past creating the covariate tables?

Or should I better edit this directly in the hydrated package?

covariateSettings <- list(list(list(fnct = 'createCovariateSettings',
                                    settings = list(FeatureExtraction::createCovariateSettings(useDemographicsGender = T,
                                                                                               longTermStartDays = -183,
                                                                                               endDays = -4,
                                                                                               useDrugGroupEraLongTerm = T),
                                                    FeatureExtraction::createCovariateSettings(useConditionGroupEraAnyTimePrior = T,
                                                                                               endDays = 0)))
)
lhjohn commented 3 years ago

Ok, now that I think about it, I can probably just do this?

covariateSettings <- list(list(list(fnct = 'createCovariateSettings',
                                    settings = FeatureExtraction::createCovariateSettings(useDemographicsGender = T,
                                                                                               longTermStartDays = -183,
                                                                                               endDays = -4,
                                                                                               useDrugGroupEraLongTerm = T)),
                               list(fnct = 'createCovariateSettings',
                                    settings = FeatureExtraction::createCovariateSettings(useConditionGroupEraAnyTimePrior = T,
                                                                                               endDays = 0)))
)
jreps commented 3 years ago

in general this should work:

covariateSettings <- list(FeatureExtraction::createCovariateSettings(useDemographicsGender = T, longTermStartDays = -183, endDays = -4, useDrugGroupEraLongTerm = T),

FeatureExtraction::createCovariateSettings(useConditionGroupEraAnyTimePrior = T, endDays = 0) )

but if you want to edit the prediction json then try something like this should work: list( list(fnct = 'createCovariateSettings', settings = FeatureExtraction::createCovariateSettings(useDemographicsGender = T, longTermStartDays = -183, endDays = -4, useDrugGroupEraLongTerm = T) ),

list(fnct = 'createCovariateSettings', settings = FeatureExtraction::createCovariateSettings(useConditionGroupEraAnyTimePrior = T, endDays = 0) ) )

lhjohn commented 3 years ago

Thank you @jreps, those worked.