Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierlabayle committed Aug 10, 2023
1 parent 19e27ee commit 1ae36d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
6 changes: 3 additions & 3 deletions examples/double_robustness.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ that we now have full coverage of the ground truth.

function tmle_inference(data)
Ψ = ATE(
:Y,
(Tcat=(case=1.0, control=0.0),),
[:W]
outcome=:Y,
treatment=(Tcat=(case=1.0, control=0.0),),
confounders=[:W]
)
result, _ = tmle!(Ψ, data; verbosity=0)
tmleresult = tmle(result)
Expand Down
27 changes: 11 additions & 16 deletions examples/super_learning.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,37 +179,32 @@ nothing # hide
Let us move to the targeted estimation step itself. We define the target estimand (the ATE) and the nuisance estimands specification:
=#
Ψ = ATE(
outcome = :Y,
treatment = (T=(case=true, control=false),),
confounders = [:W₁, :W₂]
outcome=:Y,
treatment=(T=(case=true, control=false),),
confounders=[:W₁, :W₂],
outcome_model=Q_super_learner,
treatment_model=G_super_learner
)

η_spec = NuisanceSpec(
Q_super_learner,
G_super_learner
)

nothing # hide

#=
Finally run the TMLE procedure and check the result
=#
tmle_result, cache = tmle!Ψ, η_spec, dataset)
tmle_result, _ = tmle!, dataset)

test_result = OneSampleTTest(tmle_result.tmle, ψ₀)
test_result = OneSampleTTest(tmle(tmle_result), ψ₀)

#=
Now, what if we had used linear models only instead of the Super Learner? This is easy to check
=#
setmodel!.scm.Y, LinearRegressor())
setmodel!.scm.T, LogisticClassifier())

η_spec_linear = NuisanceSpec(
LinearRegressor(),
LogisticClassifier(lambda=0)
)

tmle_result_linear, cache = tmle!Ψ, η_spec_linear, dataset)
tmle_result_linear, cache = tmle!(Ψ, dataset)

test_result_linear = OneSampleTTest(tmle_result_linear.tmle, ψ₀)
test_result_linear = OneSampleTTest(tmle(tmle_result_linear), ψ₀)

#
using Test # hide
Expand Down

0 comments on commit 1ae36d4

Please sign in to comment.