Skip to content

Commit

Permalink
possibly fix docs home
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierlabayle committed Feb 11, 2025
1 parent 3f4e706 commit 5a9b9b3
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function tmle_estimates(data)
G=MLJLinearModels.LogisticClassifier()
)
Ψ̂ = TMLEE(models=models, weighted=true)
Ψ = TMLE.ATE(;
Ψ = ATE(;
outcome=:Y,
treatment_values=(T=(case=true, control = false),),
treatment_confounders=(:W,)
Expand All @@ -60,14 +60,13 @@ function tmle_estimates(data)
return TMLE.estimate(Ψ̂ₙ)
end
function bootstrap_analysis(;B=100, α=0, β=1, γ=-1, n=100, ATE=α+γ)
function bootstrap_analysis(;B=100, α=0, β=1, γ=-1, n=100, ATE=α+γ)
Random.seed!(123)
β̂s_confounded = Vector{Float64}(undef, B)
tmles_confounded = Vector{Float64}(undef, B)
β̂s_unconfounded = Vector{Float64}(undef, B)
tmles_unconfounded = Vector{Float64}(undef, B)
for b in 1:B
@info(string("Bootstrap iteration ", b))
data_confounded = generate_confounded(;α=α, β=β, γ=γ, n=n)
β̂s_confounded[b] = linear_model_coef(data_confounded)
tmles_confounded[b] = tmle_estimates(data_confounded)
Expand All @@ -78,13 +77,13 @@ function bootstrap_analysis(;B=100, α=0, β=1, γ=-1, n=100, ATE=α+γ)
return β̂s_confounded, β̂s_unconfounded, tmles_confounded, tmles_unconfounded
end
function plot(β̂s_confounded, β̂s_unconfounded, tmles_confounded, tmles_unconfounded, β, ATE)
function plot(β̂s_confounded, β̂s_unconfounded, tmles_confounded, tmles_unconfounded, β, ATE)
fig = Figure(size=(1000, 800))
ax = Axis(fig[1, 1], title="Distribution of Linear Model's and TMLE's Estimates", yticks=(1:2, ["Confounded", "Unconfounded"]))
labels = vcat(repeat(["Confounded"], length(β̂s_confounded)), repeat(["Unconfounded"], length(β̂s_unconfounded)))
rainclouds!(ax, labels, vcat(β̂s_confounded, β̂s_unconfounded), orientation = :horizontal, color=(:blue, 0.5))
rainclouds!(ax, labels, vcat(tmles_confounded, tmles_unconfounded), orientation = :horizontal, color=(:orange, 0.5))
vlines!(ax, ATE, label="ATE", color=:green)
vlines!(ax, ATE, label="ATE", color=:green)
vlines!(ax, β, label="β", color=:red)
Legend(fig[1, 2],
Expand All @@ -101,10 +100,15 @@ n = 1000
α = 0
β = 1
γ = -1
ATE = β + γ
β̂s_confounded, β̂s_unconfounded, tmles_confounded, tmles_unconfounded = bootstrap_analysis(;B=B, α=α, β=β, γ=γ, n=n, ATE=ATE)
plot(β̂s_confounded, β̂s_unconfounded, tmles_confounded, tmles_unconfounded, β, ATE)
ATE₀ = β + γ
β̂s_confounded, β̂s_unconfounded, tmles_confounded, tmles_unconfounded = bootstrap_analysis(;B=B, α=α, β=β, γ=γ, n=n, ATE₀=ATE₀)
fig = plot(β̂s_confounded, β̂s_unconfounded, tmles_confounded, tmles_unconfounded, β, ATE₀)
nothing
save("home_simulation.png", fig)
```

[]("home_simulation.png")

## Installation

TMLE.jl can be installed via the Package Manager and supports Julia `v1.10` and greater.
Expand Down

0 comments on commit 5a9b9b3

Please sign in to comment.