nt-williams / lmtp

:package: Non-parametric Causal Effects Based on Modified Treatment Policies :crystal_ball:
http://www.beyondtheate.com
GNU Affero General Public License v3.0
55 stars 16 forks source link

Error in glm.fit running vignette #97

Closed jvpoulos closed 3 years ago

jvpoulos commented 3 years ago

Running the vignette (or example 2.1. in the CRAN manual) yields the error when calling lmtp_tmle:

Loading required package: nnls Error in glm.fit(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, : object 'fit' not found

R session info:

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.10

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] nnls_1.4        lmtp_0.9.1.9000

loaded via a namespace (and not attached):
 [1] progressr_0.7.0     codetools_0.2-16    listenv_0.8.0       future_1.21.0       digest_0.6.27       foreach_1.5.1       assertthat_0.2.1    parallelly_1.25.0  
 [9] R6_2.5.0            future.apply_1.7.0  origami_1.0.3       data.table_1.14.0   gam_1.20            generics_0.1.0      splines_4.0.2       iterators_1.0.13   
[17] tools_4.0.2         parallel_4.0.2      yaml_2.2.1          abind_1.4-5         compiler_4.0.2      SuperLearner_2.0-28 globals_0.14.0  
nt-williams commented 3 years ago

Hi @jvpoulos, it looks like you're using the development version of the package (0.9.1.9000) but running an example from the current release version on CRAN. The development version has a new parameter intervention_type that requires being specified to "mtp" if the shift function is a modified treatment policy (as is the case with example 2.1), issue #94 . Looking at the manual from the development version you should see:

  # Example 2.1
  # Longitudinal setting, time-varying continuous exposure bounded by 0,
  # time-varying covariates, and a binary outcome with no loss-to-follow-up.
  # Interested in the effect of a treatment policy where exposure decreases by
  # one unit at every time point if an observations observed exposure is greater
  # than or equal to 2. The true value under this intervention is about 0.305.
  head(sim_t4)
  a <- c("A_1", "A_2", "A_3", "A_4")
  tv <- list(c("L_1"), c("L_2"), c("L_3"), c("L_4"))
  d <- function(data, trt) {
    a <- data[[trt]]
    (a - 1) * (a - 1 >= 1) + a * (a - 1 < 1)
  }

  # BONUS: progressr progress bars!
  progressr::handlers(global = TRUE)

  lmtp_tmle(sim_t4, a, "Y", time_vary = tv, shift = d, folds = 2, intervention_type = "mtp")