Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using stremr without monitoring #38

Open
marycombs opened this issue Apr 15, 2018 · 7 comments
Open

using stremr without monitoring #38

marycombs opened this issue Apr 15, 2018 · 7 comments

Comments

@marycombs
Copy link

marycombs commented Apr 15, 2018

Is it possible to use stremr without a monitoring variable? There does not seem to be a default for MONITOR in defineIntervedTRT(), so do I have to construct a pseudo monitoring variable for the function to work?

Thanks

@osofr
Copy link
Collaborator

osofr commented Apr 16, 2018

Certainly, everything should work fine without monitoring variable. Just never use any propensity scores for monitoring and don't define the monitoring variable name when loading the data (i.e., leave it as the default)

@osofr osofr closed this as completed Apr 16, 2018
@marycombs
Copy link
Author

marycombs commented Apr 16, 2018

I believe I have done as you describe -- can you help identify what is wrong with my minimal working example below? It breaks at the defineIntervedTRT() step.

require(stremr)
require(data.table)

# EXAMPLE WITH CENSORING
data(OdataCatCENS)
test_dat <- as.data.table(OdataCatCENS, key=c(ID, t))
test_dat <- test_dat[ , !c( "CatC" , "N" , "lastNat1") ]

# Regressions for modeling the exposure (TRT)
gform_TRT <- "TI ~ CVD + highA1c"
     
# Regressions for modeling censoring (CENS)
gform_CENS <- c("C ~ highA1c")

# Define dynamic rule: dhigh
test_dat <- defineIntervedTRT(test_dat, theta = c(1), ID = "ID", t = "t",
 I = "highA1c", CENS = "C", TRT = "TI", new.TRT.names = c( "dhigh" ), 
 return.allcolumns = TRUE)
     
# Estimate IPW-based hazard and survival (KM) for a rule "dhigh":
IPW_KM_res <- stremr(test_dat , intervened_TRT = "dhigh",
  ID = "ID", t = "t", covars = c("highA1c"),
  CENS = "C", gform_CENS = gform_CENS,
  TRT = "TI", gform_TRT = gform_TRT, OUTCOME = "Y.tplus1")
     
# Survival estimates by time:
IPW_KM_res$IPW_estimates
# Input data:
IPW_KM_res$dataDT

Edit: Changed a reference to MONITOR and lastNat1 in the stremr call. This is downstream of the defineIntervedTRT call though, so does not alter where the code first breaks.

@osofr
Copy link
Collaborator

osofr commented Apr 16, 2018

Sure, happy to help, would you mind copy pastying the entire log, including all errors?

Also, why are you testing the example with categorical censoring, any specific reason for that?

@osofr osofr reopened this Apr 16, 2018
@marycombs
Copy link
Author

I want to use a dynamic treatment rule, and the example I found in stremr documentation with DTR has categorical censoring -- you'll notice, however, that I am not using CatC, I am using C for censoring which is binary.

Also, I have altered the code in my original post to include libraries and exclude a errant reference to MONITOR (that was downstream of the defineIntervedTRT call, so I do not think affected where the code is breaking).

R version 3.4.1 (2017-06-30) -- "Single Candle"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> require(stremr)
R version 3.4.1 (2017-06-30) -- "Single Candle"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> 
> require(stremr)
Loading required package: stremr
stremr
Version: 0.4

stremr IS IN EARLY DEVELOPMENT STAGE.
Please be to sure to check for frequent updates and report bugs at: http://github.com/osofr/stremr
To install the latest development version of stremr, please type this in your terminal:
  devtools::install_github('osofr/stremr')

> require(data.table)
Loading required package: data.table
data.table 1.10.4.2
  The fastest way to learn (by data.table authors): https://www.datacamp.com/courses/data-analysis-the-data-table-way
  Documentation: ?data.table, example(data.table) and browseVignettes("data.table")
  Release notes, videos and slides: http://r-datatable.com
Warning message:
package 'data.table' was built under R version 3.4.2 
> 
> # EXAMPLE WITH CENSORING
> data(OdataCatCENS)
> test_dat <- as.data.table(OdataCatCENS, key=c(ID, t))
> test_dat <- test_dat[ , !c( "CatC" , "N" , "lastNat1") ]
> 
> # Regressions for modeling the exposure (TRT)
> gform_TRT <- "TI ~ CVD + highA1c"
>      
> # Regressions for modeling censoring (CENS)
> gform_CENS <- c("C ~ highA1c")
> 
> # Define dynamic rule: dhigh
> test_dat <- defineIntervedTRT(test_dat, theta = c(1), ID = "ID", t = "t",
+  I = "highA1c", CENS = "C", TRT = "TI", new.TRT.names = c( "dhigh" ), 
+  return.allcolumns = TRUE)
Error in names(data) %in% varname : 
  argument "MONITOR" is missing, with no default
>      
> # Estimate IPW-based hazard and survival (KM) for a rule "dhigh":
> IPW_KM_res <- stremr(test_dat , intervened_TRT = "dhigh",
+   ID = "ID", t = "t", covars = c("highA1c"),
+   CENS = "C", gform_CENS = gform_CENS,
+   TRT = "TI", gform_TRT = gform_TRT, OUTCOME = "Y.tplus1")
Error in CheckVarNameExists(OData$dat.sVar, Nnode) : 
  variable name N not found in data input
>      
> # Survival estimates by time:
> IPW_KM_res$IPW_estimates
Error: object 'IPW_KM_res' not found
> # Input data:
> IPW_KM_res$dataDT
Error: object 'IPW_KM_res' not found
> 

@osofr
Copy link
Collaborator

osofr commented Apr 16, 2018 via email

@marycombs
Copy link
Author

Thank you!

@marycombs
Copy link
Author

FYI noticed I had an older version of stremr -- the bug does not appear in the newer version. Thanks for your help, Oleg!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants