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

"id = " generating errors in lmtp_tmle() #105

Open
joshua-nugent opened this issue Oct 21, 2021 · 0 comments
Open

"id = " generating errors in lmtp_tmle() #105

joshua-nugent opened this issue Oct 21, 2021 · 0 comments

Comments

@joshua-nugent
Copy link

joshua-nugent commented Oct 21, 2021

Describe the issue
Error messages arising when using the "id" option in lmtp_tmle().

reprex

library(lmtp)

# Start with documentation example
set.seed(56)
n <- 1000
W <- rnorm(n, 10, 5)
A <- 23 + 5*W + rnorm(n)
Y <- 7.2*A + 3*W + rnorm(n)

policy <- function(data, x) {
  (data[[x]] > 80)*(data[[x]] - 15) + (data[[x]] <= 80)*data[[x]]
}

e0 <- data.frame(W, A, Y)
# This works fine, as per example in the documentation
lmtp_tmle(
  data = e0,
  "A", "Y", "W", shift = policy,
  outcome_type = "continuous",
  intervention_type = "mtp"
)

n_clusters <- 4
set.seed(1)
e1 <- data.frame(W, A, Y, CL = rep(1:n_clusters, each = n / n_clusters))

lmtp_tmle( # folds < clusters
  data = e1, "A", "Y", "W", shift = policy,
  outcome_type = "continuous", .SL_folds = 2,
  intervention_type = "mtp", id = "CL",
)

lmtp_tmle( # folds = clusters
  data = e1, "A", "Y", "W", shift = policy,
  outcome_type = "continuous", .SL_folds = 4,
  intervention_type = "mtp", id = "CL",
)

lmtp_tmle( # folds > clusters
  data = e1, "A", "Y", "W", shift = policy,
  outcome_type = "continuous", .SL_folds = 10,
  intervention_type = "mtp", id = "CL",
)

More information on how and why to use a reprex can be found here.

Expected behavior
Larger standard errors than when using same data without "id" option.

Please include your R session info:

R version 4.1.1 (2021-08-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 11.6

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] lmtp_1.0.0

loaded via a namespace (and not attached):
 [1] compiler_4.1.1      generics_0.1.0      nnls_1.4           
 [4] tools_4.1.1         SuperLearner_2.0-28 codetools_0.2-18   
 [7] splines_4.1.1       gam_1.20            data.table_1.14.2  
[10] iterators_1.0.13    foreach_1.5.1 

And lastly, please be kind and respectful 😄

Thanks for your work on this!

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