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

timepoints() fails when SL is not used to model treatment #51

Open
sgruber65 opened this issue Feb 20, 2022 · 0 comments
Open

timepoints() fails when SL is not used to model treatment #51

sgruber65 opened this issue Feb 20, 2022 · 0 comments

Comments

@sgruber65
Copy link

Hi,
When I model treatment using glm, a subsequent call to timepoints() fails. The error message is:

Error in terms.formula(newformula, specials = names(attr(termobj, "specials"))) :
invalid model formula in ExtractVars
In addition: Warning message:
In if (class(SL.trt) != "SuperLearner") { :
the condition has length > 1 and only the first element will be used

Here is a reproducible example straight from the survtmle help file:

set.seed(1234)
n <- 200
trt <- rbinom(n, 1, 0.5)
adjustVars <- data.frame(W1 = round(runif(n)), W2 = round(runif(n, 0, 2)))
ftime <- round(1 + runif(n, 1, 4) - trt + adjustVars$W1 + adjustVars$W2)
ftype <- round(runif(n, 0, 1))

fit1 <- survtmle(
  ftime = ftime, ftype = ftype,
  trt = trt, adjustVars = adjustVars,
  glm.trt = "W1 + W2",
  glm.ftime = "trt + W1 + W2",
  glm.ctime = "trt + W1 + W2",
  method = "mean", t0 = 6
)
\# the next call  fails
timepoints(fit1, t = 4)

But if instead we specify SL.trt = "SL.glm", it works fine.

fit1.alt <- survtmle(
  ftime = ftime, ftype = ftype,
  trt = trt, adjustVars = adjustVars,
  SL.trt = "SL.glm",
  glm.ftime = "trt + W1 + W2",
  glm.ctime = "trt + W1 + W2",
  method = "mean", t0 = 6
)
timepoints(fit1.alt, t=4)

One clue: this line in the checkInputs function
tglm <- any(class(object$trtMod[[1]]) %in% c("glm", "speedglm"))
returns FALSE if we specify glm.trt, because class(object$trtMod) is not a list (it evaluates to: "glm, lm")

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

1 participant