OHDSI Home | Forums | Wiki | Github

Adding Additional Characterizations to Study

(Karthik) #1

Hi All,

I’m trying to add some extra characterizations for an estimation study we are doing. In particular, we wanted to add statistics of Age at Index to our results. With @Patrick_Ryan’s help, I found that covariateId 1002 was what I needed.

When I tried running the following code

  covariateSettings <- FeatureExtraction::createDefaultCovariateSettings(includedCovariateIds = c(1002))
  covariateData2 <- FeatureExtraction::getDbCovariateData(connectionDetails = connectionDetails,
                                                          cdmDatabaseSchema = cdmDatabaseSchema,
                                                          cohortDatabaseSchema = cohortDatabaseSchema,
                                                          cohortTable = cohortTable,
                                                          cohortId = 1771647,
                                                          covariateSettings = covariateSettings,
                                                          aggregated = TRUE)

I got this error:

Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  : 
  org.json.JSONException: JSONObject["isBinary"] not found.

However, when I call FeatureExtration::createCovariateSettings() and list out all the parameters I want, it works for me. Is there a way to call createDefaultCovariateSettings() and enable one of the demographics covariates?

Also, is there a way to add this to Table1? When I get the above working with createCovariateSettings(…), I make this call:


However, I don’t see the Age statistics. I only see the AgeGroup stats, but when I call covariateData2$covariatesContinuous, I see the Age at Index stats. @schuemie do you have any recommendations?

Thanks in advance!

(Karthik) #2

For Table1, it looks like I need to create a custom Table1 specification similar to the getDefaultTable1Specifications function.

(Martijn Schuemie) #3

Hi @cukarthik!

Sorry about the cryptic error message. Here’s what’s happening: you specified a single covariate ID (1002), which corresponds to age as a continuous variable. However, the default set of covariates does not include this covariate (instead it includes age as 5-year bins). So you restrict the analysis to a covariate that will not be constructed.

To answer your first question: If you want to use all the default covariate settings except change the age from group to continuous variable, here’s how to do that:

Just to see how it works, you could try:

exampleSettings <- createCovariateSettings(useDemographicsAge = TRUE,
                                           useDemographicsAgeGroup = TRUE)

which will return:


[1] TRUE

[1] TRUE

So know you know the names of the two variables you care about: DemographicsAge and DemographicsAgeGroup. Now you can create a default set of covariates, and just change these variables:

covSettings <- createDefaultCovariateSettings()
covSettings$DemographicsAgeGroup <- FALSE
covSettings$DemographicsAge <- TRUE

Don’t restrict to covariate ID 1002, or you’ll only get the age covariate (although now it will not throw an error).

To answer your last question: to generate a table 1, you’ll need to modify the table 1 specifications. You can use the getDefaultTable1Specifications function to get to specifications for the default set of covariates. I’ll leave it to you to figure out how to modify those to use the continuous age variable instead :wink: Once you’re done, you can use these specifications as input to the createTable1 function

(Vojtech Huser) #4

Me and Sigfried were also struggling with using the FeatureExtraction package. I am glad we are not the only ones.

Martijn, in your solution, you are still using the function createDefaultCovariateSettings and customizing it afterwards.

Is there a way to achieve that with createCustomCovariateSettings?

Our goal was to generate features about the cohort that temporality live after index event. E.g., how many HIV viral load tests the patient had 365 days after index. All the default covariates are for PS purposes and hence operate mostly prior index. We were hoping to use the FeatureExtraction package to describe a cohort (and not be restricted to time prior index time). We had to use custom SQL because it was hard to troubleshoot the FeatureExtraction error messages.

We did study the docs. E.g., here http://ohdsi.github.io/FeatureExtraction/articles/CreatingCustomCovariateBuilders.html#example-function-1

We also had exactly the same challenge with Table1 configurations. Please consider posting your final working code.