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

Provide better feedback when there's an intervention type error #98

Closed nt-williams closed 2 weeks ago

nt-williams commented 2 years ago

Capture this error message and indicate setting intervention_type = "mtp" will likely fix it.

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
kathoffman commented 1 year ago

I've noticed this error also occurs if staticbinary* is accidentally used with a numerical treatment. Perhaps this could be incorporated into suggestions for the user to debug?

Reprex is the same as Example 4.1 in ?lmtp_tmle, with only the shift changed from NULL to static_binary_on.

library(lmtp)

A <- c("A1", "A2")
L <- list(c("L1"), c("L2"))
C <- c("C1", "C2")
Y <- "Y"

progressr::with_progress(
  lmtp_tmle(data = sim_cens, 
            A,
            time_vary = L, 
            Y,
            cens = C, 
            shift = static_binary_on,
            folds = 2)
)