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

Supports general submodels and a bunch of new parameters #75

Open
wants to merge 66 commits into
base: devel
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
5552f70
submodels
Sep 5, 2021
15d0089
submodels
Sep 5, 2021
8d86c53
supports general submodels. Tests pass
Sep 5, 2021
4ceae2c
supports general submodel and weights. JK on previous commit
Sep 5, 2021
97b765e
supports general submodel and weights. JK on previous commit
Sep 5, 2021
3d252ac
supports general submodel and weights. JK on previous commit
Sep 5, 2021
a7a1dda
fix ATT and ATC submodels
Sep 5, 2021
742f1c9
REFERENCE CHANGES HERE
Sep 5, 2021
64583b0
towards spCATE
Sep 6, 2021
5a80be0
implemented spCATE PARAM
Sep 6, 2021
870e1a1
added more sp params
Sep 6, 2021
ceac71b
causalGLM seems to work
Sep 6, 2021
ec88bb9
hi
Sep 6, 2021
7ba9492
Update tmle3_Update.R
Larsvanderlaan Sep 6, 2021
9b64c82
Remove built in submodels/losses
Larsvanderlaan Sep 6, 2021
01b1116
Delete submodels_semiparametric.R
Larsvanderlaan Sep 6, 2021
a22e578
np params
Sep 6, 2021
a8ca892
Merge branch 'general_submodels_devel' of https://github.com/tlverse/…
Sep 6, 2021
1142b6b
more np
Sep 6, 2021
a4584d1
minr bug fixes to npOR
Sep 6, 2021
6bd79b4
testing
Sep 6, 2021
0f15fc0
hi
Sep 6, 2021
b017418
more tests
Sep 6, 2021
eaff276
more tests
Sep 6, 2021
d9f2ee3
ran make style
Sep 6, 2021
e97a39f
ran make style
Sep 6, 2021
667e24c
wait
Sep 6, 2021
2d3aa6e
fix bug
Sep 6, 2021
e349397
format
Sep 6, 2021
de1a3f1
format
Sep 6, 2021
759dca0
fix documentation bug
Sep 6, 2021
d90cb6e
remove glm_sp docs
Sep 6, 2021
63a41a1
changes
Sep 6, 2021
fca50f6
changes
Sep 6, 2021
7253a6c
changes
Sep 6, 2021
436581f
change to default for spCausal
Sep 6, 2021
03f22c7
change to default for spCausal
Sep 6, 2021
c19995e
change to default for spCausal
Sep 6, 2021
e4ee0f5
change to default for spCausal
Sep 6, 2021
da0e4a8
change to default for spCausal
Sep 7, 2021
fc438e4
change to default for spCausal
Sep 7, 2021
e218916
fix bug tmle3_fit initial est if no full fit
Sep 7, 2021
e094a76
fix
Sep 7, 2021
701b5a5
fix
Sep 7, 2021
2fff29b
fix
Sep 7, 2021
2244687
fix
Sep 7, 2021
59a9301
fix
Sep 7, 2021
9808493
add npTSM
Sep 7, 2021
3f5b0f7
npRR
Sep 7, 2021
9c55096
bounded outcomes
Sep 7, 2021
d75be43
bounded outcomes
Sep 7, 2021
ed89de8
bounded outcomes
Sep 7, 2021
469e7f8
bounded outcomes
Sep 7, 2021
4d4fb2f
plz
Sep 7, 2021
48324de
small
Sep 7, 2021
ab16187
added Param_coxph
Sep 8, 2021
f019a0f
added Param_coxph
Sep 8, 2021
1fcd721
added Param_coxph
Sep 8, 2021
a6b3587
change OR default submodel
Sep 8, 2021
7969124
sort of fixed coxph
Sep 9, 2021
e9d587f
sort of fixed coxph
Sep 9, 2021
3a3bfa8
hi
Sep 9, 2021
d340dc9
hi
Sep 9, 2021
fef3613
plz dont break
Sep 9, 2021
0787f9b
ATE weights
Larsvanderlaan Apr 7, 2022
dd189d8
ATE weights
Larsvanderlaan Apr 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
minr bug fixes to npOR
Lars van der Laan committed Sep 6, 2021
commit a4584d1a557dddd43dcb7010652037124abf7f46
6 changes: 5 additions & 1 deletion R/Param_npCATE.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#' Average Treatment Effect
#' Nonparametric inference for user-specified parametric working models for the conditional treatment effect.
#' The true conditional average treatment effect is projected onto a parametric working model using least-squares regression.
#' Unlike \code{Param_npCATT}, this function uses all observations to compute the projection.
#' This can be used to assess heterogeneity of the average treatment effect.
#' We note that `formula_CATE = ~ 1` gives an estimator of the nonparametric average treatment effect (ATE).
#'
#' Parameter definition for the Average Treatment Effect (ATE).
#' @importFrom R6 R6Class
7 changes: 4 additions & 3 deletions R/Param_npCATT.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' Average Treatment Effect
#'
#' Parameter definition for the Average Treatment Effect (ATE).
#' Nonparametric inference for user-specified parametric working models for the conditional treatment effect.
#' The true conditional average treatment effect is projected onto a parametric working model using only individuals with `A=1` (among the treated).
#' This can be used to assess heterogeneity of the average treatment effect and avoids positivity issues by focusing on best approximating the conditional average treatment effect ampng the treated.
#' We note that `formula_CATT = ~ 1` gives an estimator of the nonparametric average treatment effect among the treated (ATT).
#' @importFrom R6 R6Class
#' @importFrom uuid UUIDgenerate
#' @importFrom methods is
49 changes: 28 additions & 21 deletions R/Param_npOR.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#' Average Treatment Effect
#'
#' Nonparametric inference for user-specified parametric working models for the conditional odds ratio between two binary variables
#' The true conditional odds ratio is projected onto a parametric working model using logistic-regression.
#' This can be used to assess heterogeneity of the odds ratio.
#' We note that `formula_logOR = ~ 1` gives an estimator of the nonparametric marginal odds ratio among the treated.
#' The parametric model is at the log-scale and therefore the coefficients returned code the linear predictor for the `log`-conditional odds ratio.
#' Parameter definition for the Average Treatment Effect (ATE).
#' @importFrom R6 R6Class
#' @importFrom uuid UUIDgenerate
@@ -17,7 +20,7 @@
#' \describe{
#' \item{\code{observed_likelihood}}{A \code{\link{Likelihood}} corresponding to the observed likelihood
#' }
#' \item{\code{formula_OR}}{...
#' \item{\code{formula_logOR}}{...
#' }
#' \item{\code{intervention_list_treatment}}{A list of objects inheriting from \code{\link{LF_base}}, representing the treatment intervention.
#' }
@@ -48,7 +51,7 @@ Param_npOR <- R6Class(
class = TRUE,
inherit = Param_base,
public = list(
initialize = function(observed_likelihood, formula_OR =~ 1, intervention_list_treatment, intervention_list_control, outcome_node = "Y") {
initialize = function(observed_likelihood, formula_logOR =~ 1, intervention_list_treatment, intervention_list_control, outcome_node = "Y") {
super$initialize(observed_likelihood, list(), outcome_node)
if (!is.null(observed_likelihood$censoring_nodes[[outcome_node]])) {
# add delta_Y=0 to intervention lists
@@ -57,7 +60,7 @@ Param_npOR <- R6Class(
intervention_list_treatment <- c(intervention_list_treatment, censoring_intervention)
intervention_list_control <- c(intervention_list_control, censoring_intervention)
}
private$.formula_OR <- formula_OR
private$.formula_logOR <- formula_logOR
private$.cf_likelihood_treatment <- CF_Likelihood$new(observed_likelihood, intervention_list_treatment)
private$.cf_likelihood_control <- CF_Likelihood$new(observed_likelihood, intervention_list_control)
},
@@ -75,11 +78,11 @@ Param_npOR <- R6Class(
intervention_nodes <- union(names(self$intervention_list_treatment), names(self$intervention_list_control))

W <- tmle_task$get_tmle_node("W")
V <- model.matrix(self$formula_OR, as.data.frame(W))
V <- model.matrix(self$formula_logOR, as.data.frame(W))
A <- tmle_task$get_tmle_node("A", format = TRUE)[[1]]
Y <- tmle_task$get_tmle_node("Y", format = TRUE)[[1]]
W_train <- training_task$get_tmle_node("W")
V_train <- model.matrix(self$formula_OR, as.data.frame(W_train))
V_train <- model.matrix(self$formula_logOR, as.data.frame(W_train))
A_train <- training_task$get_tmle_node("A", format = TRUE)[[1]]
Y_train <- training_task$get_tmle_node("Y", format = TRUE)[[1]]

@@ -93,29 +96,33 @@ Param_npOR <- R6Class(
Qorig <- Q
Q0 <- bound(Q0, 0.005)
Q1 <- bound(Q1, 0.005)
beta <- get_beta(W_train, A_train, self$formula_OR, Q1, Q0, family = binomial(), weights = self$weights)
beta <- get_beta(W_train, A_train, self$formula_logOR, Q1, Q0, family = binomial(), weights = self$weights)

Q1beta <- plogis(qlogis(Q0) + V%*%beta)
ORbeta <- Q1beta*(1-Q1beta) / (Q0*(1-Q0))
omega <- (g0 + g1*ORbeta) / (g0)

sigma_rel <- Q1beta*(1-Q1beta) / (Q0*(1-Q0))


h_star <- -1*as.vector((g1*ORbeta) / (g1*ORbeta + (1-g1)))
omega <- (g0 + g1*sigma_rel) / (g0)

h_star <- -1*as.vector((g1*sigma_rel) / (g1*sigma_rel + (1-g1)))
H <- as.matrix(omega*V*(A + h_star))

# Store EIF component
EIF_Y <- NULL
EIFWA <- NULL
if(is_training_task) {
tryCatch({
scale <- apply(V,2, function(v){apply(self$weights*as.vector( Q1beta*(1-Q1beta) * Q0*(1-Q0) * g1 * (1-g1) / (g1 * Q1beta*(1-Q1beta) + (1-g1) *Q0*(1-Q0) )) * v*V,2,mean)})
scale <- apply(V,2, function(v){apply(self$weights*(A * Q1beta*(1-Q1beta) * v*V),2,mean)})
scaleinv <- solve(scale)
EIF_Y <- self$weights * (H%*% scaleinv) * (Y-Q)
EIFWA <- apply(V, 2, function(v) {
(weights*(A*v*(Q1 - Q1beta)) - mean( self$weights*(A*v*(Q1 - Q1beta))))
}) %*% scale_inv
}, error = function(...){
(self$weights*(A*v*(Q1 - Q1beta)) - mean( self$weights*(A*v*(Q1 - Q1beta))))
})

EIFWA <- EIFWA %*% scaleinv

})
} ,error = function(...) {} )
}

return(list(Y = H, EIF = list(Y = EIF_Y, WA = EIFWA)))
@@ -147,8 +154,8 @@ Param_npOR <- R6Class(
# Q <- Q_packed[[3]]
Q0 <- bound(Q0, 0.0005)
Q1 <- bound(Q1, 0.0005)
beta <- get_beta(W, A, self$formula_OR, Q1, Q0, family = binomial(), weights = weights)
V <- model.matrix(self$formula_OR, as.data.frame(W))
beta <- get_beta(W, A, self$formula_logOR, Q1, Q0, family = binomial(), weights = weights)
V <- model.matrix(self$formula_logOR, as.data.frame(W))
OR <- exp(V%*%beta)

IC <- EIF
@@ -177,16 +184,16 @@ Param_npOR <- R6Class(
update_nodes = function() {
return(c(self$outcome_node))
},
formula_OR = function(){
return(private$.formula_OR)
formula_logOR = function(){
return(private$.formula_logOR)
}
),
private = list(
.type = "OR",
.cf_likelihood_treatment = NULL,
.cf_likelihood_control = NULL,
.supports_outcome_censoring = TRUE,
.formula_OR = NULL,
.formula_logOR = NULL,
.submodel = list(Y = "gaussian_identity")
)
)
7 changes: 4 additions & 3 deletions R/Param_spCATE.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' Average Treatment Effect
#'
#' Parameter definition for the Average Treatment Effect (ATE).
#' Semiparametric estimation of the conditonal average treatment effect for arbitrary partially-linear least-squares regression models.
#' This is a semiparametric version of \code{Param_npCATT} and \code{Param_npCATE} where the parametric model for the CATE is assumed correct.
#' Assuming the semiparametric model to be true allows for some efficiency gain (when true) but may lead to less robust estimates due to misspecification.
#' Note a linear-link is used for the CATE.
#' @importFrom R6 R6Class
#' @importFrom uuid UUIDgenerate
#' @importFrom methods is
29 changes: 15 additions & 14 deletions R/Param_spOR.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' Average Treatment Effect
#'
#' Parameter definition for the Average Treatment Effect (ATE).
#' Semiparametric estimation of the conditonal odds ratio for arbitrary partially-linear logistic regression models.
#' This is a semiparametric version of \code{Param_npOR} where the parametric model for the OR is assumed correct.
#' Assuming the semiparametric model to be true allows for some efficiency gain (when true) but may lead to less robust estimates due to misspecification.
#' The parametric model is at the log-scale and therefore the coefficients returned code the linear predictor for the `log`-conditional odds ratio.
#' @importFrom R6 R6Class
#' @importFrom uuid UUIDgenerate
#' @importFrom methods is
@@ -17,7 +18,7 @@
#' \describe{
#' \item{\code{observed_likelihood}}{A \code{\link{Likelihood}} corresponding to the observed likelihood
#' }
#' \item{\code{formula_OR}}{...
#' \item{\code{formula_logOR}}{...
#' }
#' \item{\code{intervention_list_treatment}}{A list of objects inheriting from \code{\link{LF_base}}, representing the treatment intervention.
#' }
@@ -48,7 +49,7 @@ Param_spOR <- R6Class(
class = TRUE,
inherit = Param_base,
public = list(
initialize = function(observed_likelihood, formula_OR =~ 1, intervention_list_treatment, intervention_list_control, outcome_node = "Y") {
initialize = function(observed_likelihood, formula_logOR =~ 1, intervention_list_treatment, intervention_list_control, outcome_node = "Y") {
super$initialize(observed_likelihood, list(), outcome_node)
if (!is.null(observed_likelihood$censoring_nodes[[outcome_node]])) {
# add delta_Y=0 to intervention lists
@@ -57,7 +58,7 @@ Param_spOR <- R6Class(
intervention_list_treatment <- c(intervention_list_treatment, censoring_intervention)
intervention_list_control <- c(intervention_list_control, censoring_intervention)
}
private$.formula_OR <- formula_OR
private$.formula_logOR <- formula_logOR
private$.cf_likelihood_treatment <- CF_Likelihood$new(observed_likelihood, intervention_list_treatment)
private$.cf_likelihood_control <- CF_Likelihood$new(observed_likelihood, intervention_list_control)
},
@@ -75,7 +76,7 @@ Param_spOR <- R6Class(
intervention_nodes <- union(names(self$intervention_list_treatment), names(self$intervention_list_control))

W <- tmle_task$get_tmle_node("W")
V <- model.matrix(self$formula_OR, as.data.frame(W))
V <- model.matrix(self$formula_logOR, as.data.frame(W))
A <- tmle_task$get_tmle_node("A", format = TRUE)[[1]]
Y <- tmle_task$get_tmle_node("Y", format = TRUE)[[1]]
g <- self$observed_likelihood$get_likelihoods(tmle_task, "A", fold_number)
@@ -91,10 +92,10 @@ Param_spOR <- R6Class(
Qorig <- Q
Q0 <- bound(Q0, 0.005)
Q1 <- bound(Q1, 0.005)
OR <- Q1*(1-Q1) / (Q0*(1-Q0))
sigma_rel <- Q1*(1-Q1) / (Q0*(1-Q0))


h_star <- -1*as.vector((g1*OR) / (g1*OR + (1-g1)))
h_star <- -1*as.vector((g1*sigma_rel) / (g1*sigma_rel + (1-g1)))
H <- as.matrix(V*(A + h_star))

# Store EIF component
@@ -137,8 +138,8 @@ Param_spOR <- R6Class(
# Q <- Q_packed[[3]]
Q0 <- bound(Q0, 0.0005)
Q1 <- bound(Q1, 0.0005)
beta <- get_beta(W, A, self$formula_OR, Q1, Q0, family = binomial(), weights = weights)
V <- model.matrix(self$formula_OR, as.data.frame(W))
beta <- get_beta(W, A, self$formula_logOR, Q1, Q0, family = binomial(), weights = weights)
V <- model.matrix(self$formula_logOR, as.data.frame(W))
OR <- exp(V%*%beta)

IC <- EIF
@@ -167,16 +168,16 @@ Param_spOR <- R6Class(
update_nodes = function() {
return(c(self$outcome_node))
},
formula_OR = function(){
return(private$.formula_OR)
formula_logOR = function(){
return(private$.formula_logOR)
}
),
private = list(
.type = "OR",
.cf_likelihood_treatment = NULL,
.cf_likelihood_control = NULL,
.supports_outcome_censoring = TRUE,
.formula_OR = NULL,
.formula_logOR = NULL,
.submodel = list(Y = "gaussian_identity")
)
)
26 changes: 14 additions & 12 deletions R/Param_spRR.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#' Average Treatment Effect
#'
#' Parameter definition for the Average Treatment Effect (ATE).
#' Semiparametric estimation of the conditonal relative risk/treatment-effect for arbitrary partially-linear log-linear/link regression models.
#' Arbitrary user-specified parametric models for the conditional relative-risk are supported.
#` This method implements semiparametric efficient relative-risk regression for nonnegative outcomes.
#' Assuming the semiparametric model to be true allows for some efficiency gain (when true) but may lead to less robust estimates due to misspecification.
#' The parametric model is at the log-scale and therefore the coefficients returned code the linear predictor for the `log`-relative-risk.
#' @importFrom R6 R6Class
#' @importFrom uuid UUIDgenerate
#' @importFrom methods is
@@ -17,7 +19,7 @@
#' \describe{
#' \item{\code{observed_likelihood}}{A \code{\link{Likelihood}} corresponding to the observed likelihood
#' }
#' \item{\code{formula_RR}}{...
#' \item{\code{formula_logRR}}{...
#' }
#' \item{\code{intervention_list_treatment}}{A list of objects inheriting from \code{\link{LF_base}}, representing the treatment intervention.
#' }
@@ -48,7 +50,7 @@ Param_spRR <- R6Class(
class = TRUE,
inherit = Param_base,
public = list(
initialize = function(observed_likelihood, formula_RR =~ 1, intervention_list_treatment, intervention_list_control, outcome_node = "Y") {
initialize = function(observed_likelihood, formula_logRR =~ 1, intervention_list_treatment, intervention_list_control, outcome_node = "Y") {
super$initialize(observed_likelihood, list(), outcome_node)
if (!is.null(observed_likelihood$censoring_nodes[[outcome_node]])) {
# add delta_Y=0 to intervention lists
@@ -57,7 +59,7 @@ Param_spRR <- R6Class(
intervention_list_treatment <- c(intervention_list_treatment, censoring_intervention)
intervention_list_control <- c(intervention_list_control, censoring_intervention)
}
private$.formula_RR <- formula_RR
private$.formula_logRR <- formula_logRR
private$.cf_likelihood_treatment <- CF_Likelihood$new(observed_likelihood, intervention_list_treatment)
private$.cf_likelihood_control <- CF_Likelihood$new(observed_likelihood, intervention_list_control)
},
@@ -75,7 +77,7 @@ Param_spRR <- R6Class(
intervention_nodes <- union(names(self$intervention_list_treatment), names(self$intervention_list_control))

W <- tmle_task$get_tmle_node("W")
V <- model.matrix(self$formula_RR, as.data.frame(W))
V <- model.matrix(self$formula_logRR, as.data.frame(W))
A <- tmle_task$get_tmle_node("A", format = TRUE)[[1]]
Y <- tmle_task$get_tmle_node("Y", format = TRUE)[[1]]

@@ -144,8 +146,8 @@ Param_spRR <- R6Class(

Q0 <- pmax(Q0, 0.0005)
Q1 <- pmax(Q1, 0.0005)
beta <- get_beta(W, A, self$formula_RR, Q1, Q0, family = poisson(), weights = weights)
V <- model.matrix(self$formula_RR, as.data.frame(W))
beta <- get_beta(W, A, self$formula_logRR, Q1, Q0, family = poisson(), weights = weights)
V <- model.matrix(self$formula_logRR, as.data.frame(W))
RR <- exp(V%*%beta)

IC <- as.matrix(EIF)
@@ -174,16 +176,16 @@ Param_spRR <- R6Class(
update_nodes = function() {
return(c(self$outcome_node))
},
formula_RR = function(){
return(private$.formula_RR)
formula_logRR = function(){
return(private$.formula_logRR)
}
),
private = list(
.type = "RR",
.cf_likelihood_treatment = NULL,
.cf_likelihood_control = NULL,
.supports_outcome_censoring = TRUE,
.formula_RR = NULL,
.formula_logRR = NULL,
.submodel = list(Y = "poisson_log")
)
)
6 changes: 3 additions & 3 deletions R/tmle3_Spec_npCausalGLM.R
Original file line number Diff line number Diff line change
@@ -41,13 +41,13 @@ tmle3_Spec_npCausalGLM <- R6Class(

return(likelihood)
},
make_updater = function(convergence_type = "sample_size", verbose = TRUE,...) {
make_updater = function(convergence_type = "sample_size", verbose = F,...) {
if(self$options$estimand == "CATE" || self$options$estimand == "CATT"){
updater <- tmle3_Update$new(maxit=100,one_dimensional = FALSE, verbose = verbose, constrain_step = FALSE, bounds = c(-Inf, Inf), ...)
} else if (self$options$estimand == "OR"){
updater <- tmle3_Update$new(maxit = 200, one_dimensional = TRUE, convergence_type = convergence_type, verbose = verbose,delta_epsilon = 0.001, constrain_step = TRUE, bounds = 0.0025, ...)
updater <- tmle3_Update$new(maxit = 200, one_dimensional = TRUE, convergence_type = convergence_type, verbose = verbose,delta_epsilon = 0.01, constrain_step = TRUE, bounds = 0.0025, ...)
} else if (self$options$estimand == "RR"){
updater <- tmle3_Update$new(maxit = 200, one_dimensional = TRUE, convergence_type = convergence_type, verbose = verbose, delta_epsilon = 0.001, constrain_step = TRUE, bounds = c(0.0025, Inf), ...)
updater <- tmle3_Update$new(maxit = 200, one_dimensional = TRUE, convergence_type = convergence_type, verbose = verbose, delta_epsilon = 0.01, constrain_step = TRUE, bounds = c(0.0025, Inf), ...)
}
return(updater)
},
6 changes: 3 additions & 3 deletions R/tmle3_spec_spCausalGLM.R
Original file line number Diff line number Diff line change
@@ -43,13 +43,13 @@ tmle3_Spec_spCausalGLM <- R6Class(

return(likelihood)
},
make_updater = function(convergence_type = "sample_size", verbose = TRUE,...) {
make_updater = function(convergence_type = "sample_size", verbose = F,...) {
if(self$options$estimand == "CATE"){
updater <- tmle3_Update$new(maxit=100,one_dimensional = FALSE, verbose = verbose, constrain_step = FALSE, bounds = c(-Inf, Inf), ...)
} else if (self$options$estimand == "OR"){
updater <- tmle3_Update$new(maxit = 200, one_dimensional = TRUE, convergence_type = convergence_type, verbose = verbose,delta_epsilon = 0.001, constrain_step = TRUE, bounds = 0.0025, ...)
updater <- tmle3_Update$new(maxit = 200, one_dimensional = TRUE, convergence_type = convergence_type, verbose = verbose,delta_epsilon = 0.01, constrain_step = TRUE, bounds = 0.0025, ...)
} else if (self$options$estimand == "RR"){
updater <- tmle3_Update$new(maxit = 200, one_dimensional = TRUE, convergence_type = convergence_type, verbose = verbose, delta_epsilon = 0.001, constrain_step = TRUE, bounds = c(0.0025, Inf), ...)
updater <- tmle3_Update$new(maxit = 200, one_dimensional = TRUE, convergence_type = convergence_type, verbose = verbose, delta_epsilon = 0.01, constrain_step = TRUE, bounds = c(0.0025, Inf), ...)
}
return(updater)
},
6 changes: 5 additions & 1 deletion man/Param_npCATE.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions man/Param_npCATT.Rd
14 changes: 12 additions & 2 deletions man/Param_npOR.Rd
10 changes: 8 additions & 2 deletions man/Param_spCATE.Rd
12 changes: 9 additions & 3 deletions man/Param_spOR.Rd
12 changes: 9 additions & 3 deletions man/Param_spRR.Rd
57 changes: 44 additions & 13 deletions vignettes/testing.Rmd
Original file line number Diff line number Diff line change
@@ -11,8 +11,14 @@ knitr::opts_chunk$set(echo = TRUE)


```{r}
library(sl3)
n <- 200
passes <- c()
passes1 <- c()
passes2 <- c()
for(i in 1:100){
print(i)
n <- 500
W <- runif(n, -1, 1)
A <- rbinom(n, size = 1, prob = plogis(W))
Y <- rnorm(n, mean = A+W, sd = 0.3)
@@ -25,37 +31,62 @@ learner_list <- list(A = lrnr_A, Y = lrnr_Y0W, var_Y = Lrnr_mean$new())
# spec_spCATE <- tmle3_Spec_spCausalGLM$new(~1, "CATE")
# out <- tmle3(spec_spCATE, data, node_list, learner_list = learner_list)
spec_spCATE <- tmle3_Spec_npCausalGLM$new(~1, "CATE")
out <- tmle3(spec_spCATE, data, node_list, learner_list = learner_list)
out
suppressWarnings(out <- tmle3(spec_spCATE, data, node_list, learner_list = learner_list) )
out <- out$summary
passes <- c(passes , out$lower <= 1 & out$upper >= 1)
spec_spCATE <- tmle3_Spec_npCausalGLM$new(~1, "CATT")
out <- tmle3(spec_spCATE, data, node_list, learner_list = learner_list)
out
suppressWarnings(out <- tmle3(spec_spCATE, data, node_list, learner_list = learner_list) )
out <- out$summary
passes1 <- c(passes1 , out$lower <= 1 & out$upper >= 1)
spec_spCATE <- tmle3_Spec_spCausalGLM$new(~1, "CATE")
out <- tmle3(spec_spCATE, data, node_list, learner_list = learner_list)
out
suppressWarnings(out <- tmle3(spec_spCATE, data, node_list, learner_list = learner_list) )
out <- out$summary
passes2 <- c(passes2 , out$lower <= 1 & out$upper >= 1)
print(mean(passes))
print(mean(passes1))
print(mean(passes2))
}
```




```{r}
```{r, include = F}
passes <- c()
passes1 <- c()
for(i in 1:100){
print(i)
library(sl3)
n <- 200
n <- 500
W <- runif(n, -1, 1)
A <- rbinom(n, size = 1, prob = plogis(W))
A <- rbinom(n, size = 1, prob = plogis(0))
Y <- rbinom(n, size = 1, prob = plogis(A + W))
quantile(plogis(1 + W) * (1-plogis(1 + W)) / ( plogis( W) * (1-plogis( W))))
data <- data.table(W,A,Y)
lrnr_Y0W <- Lrnr_glmnet$new()
lrnr_A <- Lrnr_glm$new()
node_list <- list (W = "W", A = "A", Y= "Y")
learner_list <- list(A = lrnr_A, Y = lrnr_Y0W)
spec_spCATE <- tmle3_Spec_spCausalGLM$new(~1, "OR")
out <- tmle3(spec_spCATE, data, node_list, learner_list = learner_list)
out
suppressWarnings(out <- tmle3(spec_spCATE, data, node_list, learner_list = learner_list))
out <- out$summary
passes <- c(passes , out$lower <= 1 & out$upper >= 1)
spec_spCATE <- tmle3_Spec_npCausalGLM$new(~1, "OR")
suppressWarnings(out <- tmle3(spec_spCATE, data, node_list, learner_list = learner_list) )
out <- out$summary
passes1 <- c(passes1 , out$lower <= 1 & out$upper >= 1)
print(mean(passes))
print(mean(passes1))
}
```