Giter Site home page Giter Site logo

using stremr without monitoring about stremr HOT 7 OPEN

marycombs avatar marycombs commented on August 9, 2024
using stremr without monitoring

from stremr.

Comments (7)

osofr avatar osofr commented on August 9, 2024

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)

from stremr.

marycombs avatar marycombs commented on August 9, 2024

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.

from stremr.

osofr avatar osofr commented on August 9, 2024

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?

from stremr.

marycombs avatar marycombs commented on August 9, 2024

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
> 

from stremr.

osofr avatar osofr commented on August 9, 2024

from stremr.

marycombs avatar marycombs commented on August 9, 2024

Thank you!

from stremr.

marycombs avatar marycombs commented on August 9, 2024

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

from stremr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.