Skip to content

Commit

Permalink
rename IATE to AIE
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierlabayle committed Aug 21, 2024
1 parent 8d9a951 commit 5de94f6
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 83 deletions.
10 changes: 5 additions & 5 deletions docs/src/user_guide/estimands.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ For a general higher-order definition, please refer to [Higher-order interaction
For two points interaction with both treatment and control levels ``0`` and ``1`` for ease of notation:

```math
IATE_{0 \rightarrow 1, 0 \rightarrow 1}(P) = \mathbb{E}[Y|do(T_1=1, T_2=1)] - \mathbb{E}[Y|do(T_1=1, T_2=0)] \\
AIE_{0 \rightarrow 1, 0 \rightarrow 1}(P) = \mathbb{E}[Y|do(T_1=1, T_2=1)] - \mathbb{E}[Y|do(T_1=1, T_2=0)] \\
- \mathbb{E}[Y|do(T_1=0, T_2=1)] + \mathbb{E}[Y|do(T_1=0, T_2=0)]
```

- Statistical Estimand (via backdoor adjustment):

```math
IATE_{0 \rightarrow 1, 0 \rightarrow 1}(P) = \mathbb{E}_{\textbf{W}}[\mathbb{E}[Y|T_1=1, T_2=1, \textbf{W}] - \mathbb{E}[Y|T_1=1, T_2=0, \textbf{W}] \\
AIE_{0 \rightarrow 1, 0 \rightarrow 1}(P) = \mathbb{E}_{\textbf{W}}[\mathbb{E}[Y|T_1=1, T_2=1, \textbf{W}] - \mathbb{E}[Y|T_1=1, T_2=0, \textbf{W}] \\
- \mathbb{E}[Y|T_1=0, T_2=1, \textbf{W}] + \mathbb{E}[Y|T_1=0, T_2=0, \textbf{W}]]
```

Expand All @@ -148,7 +148,7 @@ IATE_{0 \rightarrow 1, 0 \rightarrow 1}(P) = \mathbb{E}_{\textbf{W}}[\mathbb{E}[
A causal estimand is given by:

```@example estimands
causalΨ = IATE(
causalΨ = AIE(
outcome=:Y,
treatment_values=(
T₁=(case=1, control=0),
Expand All @@ -166,7 +166,7 @@ statisticalΨ = identify(causalΨ, scm)
or defined directly:

```@example estimands
statisticalΨ = IATE(
statisticalΨ = AIE(
outcome=:Y,
treatment_values=(
T₁=(case=1, control=0),
Expand All @@ -178,7 +178,7 @@ statisticalΨ = IATE(

- Factorial Treatments

It is possible to generate a `JointEstimand` containing all linearly independent IATEs from a set of treatment values or from a dataset. For that purpose, use the `factorialEstimand` function.
It is possible to generate a `JointEstimand` containing all linearly independent AIEs from a set of treatment values or from a dataset. For that purpose, use the `factorialEstimand` function.

## Joint And Composed Estimands

Expand Down
6 changes: 3 additions & 3 deletions docs/src/user_guide/estimation.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ result₃
nothing # hide
```

This time only the model for `Y` is fitted again while reusing the models for `T₁` and `T₂`. Finally, let's see what happens if we estimate the `IATE` between `T₁` and `T₂`.
This time only the model for `Y` is fitted again while reusing the models for `T₁` and `T₂`. Finally, let's see what happens if we estimate the `AIE` between `T₁` and `T₂`.

```@example estimation
Ψ₄ = IATE(
Ψ₄ = AIE(
outcome=:Y,
treatment_values=(
T₁=(case=true, control=false),
Expand All @@ -224,7 +224,7 @@ As explained in [Joint And Composed Estimands](@ref), a joint estimand is simply
More precisely, we would like to see if the left-hand side of this equation is equal to the right-hand side:

```math
IATE_{T_1=0 \rightarrow 1, T_2=0 \rightarrow 1} = ATE_{T_1=0 \rightarrow 1, T_2=0 \rightarrow 1} - ATE_{T_1=0, T_2=0 \rightarrow 1} - ATE_{T_1=0 \rightarrow 1, T_2=0}
AIE_{T_1=0 \rightarrow 1, T_2=0 \rightarrow 1} = ATE_{T_1=0 \rightarrow 1, T_2=0 \rightarrow 1} - ATE_{T_1=0, T_2=0 \rightarrow 1} - ATE_{T_1=0 \rightarrow 1, T_2=0}
```

For that, we need to define a joint estimand of three components:
Expand Down
6 changes: 3 additions & 3 deletions docs/src/walk_through.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ marginal_ate_t1 = ATE(
- The Interaction Average Treatment Effect:

```@example walk-through
iate = IATE(
aie = AIE(
outcome = :Y,
treatment_values = (
T₁=(case=1, control=0),
Expand All @@ -125,7 +125,7 @@ iate = IATE(
Identification is the process by which a Causal Estimand is turned into a Statistical Estimand, that is, a quantity we may estimate from data. This is done via the `identify` function which also takes in the ``SCM``:

```@example walk-through
statistical_iate = identify(iate, scm)
statistical_aie = identify(aie, scm)
```

Alternatively, you can also directly define the statistical parameters (see [Estimands](@ref)).
Expand All @@ -149,7 +149,7 @@ Statistical Estimands can be estimated without a ``SCM``, let's use the One-Step

```@example walk-through
ose = OSE()
result, cache = ose(statistical_iate, dataset)
result, cache = ose(statistical_aie, dataset)
result
```

Expand Down
2 changes: 1 addition & 1 deletion src/TMLE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using AutoHashEquals
# #############################################################################

export SCM, StaticSCM, add_equations!, add_equation!, parents, vertices
export CM, ATE, IATE
export CM, ATE, AIE
export AVAILABLE_ESTIMANDS
export factorialEstimand, factorialEstimands
export TMLEE, OSE, NAIVE
Expand Down
26 changes: 14 additions & 12 deletions src/counterfactual_mean_based/estimands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ variables(estimand::CMRelevantFactors) =
const ESTIMANDS_DOCS = Dict(
:CM => (formula="``CM(Y, T=t) = E[Y|do(T=t)]``",),
:ATE => (formula="``ATE(Y, T, case, control) = E[Y|do(T=case)] - E[Y|do(T=control)``",),
:IATE => (formula="``IATE = E[Y|do(T₁=1, T₂=1)] - E[Y|do(T₁=1, T₂=0)] - E[Y|do(T₁=0, T₂=1)] + E[Y|do(T₁=0, T₂=0)]``",)
:AIE => (formula="``AIE = E[Y|do(T₁=1, T₂=1)] - E[Y|do(T₁=1, T₂=0)] - E[Y|do(T₁=0, T₂=1)] + E[Y|do(T₁=0, T₂=0)]``",)
)

for (estimand, (formula,)) ESTIMANDS_DOCS
Expand Down Expand Up @@ -89,6 +89,8 @@ for (estimand, (formula,)) ∈ ESTIMANDS_DOCS
eval(ex)
end

const IATE = AIE

CausalCMCompositeEstimands = Union{(eval(Symbol(:Causal, x)) for x in keys(ESTIMANDS_DOCS))...}

StatisticalCMCompositeEstimand = Union{(eval(Symbol(:Statistical, x)) for x in keys(ESTIMANDS_DOCS))...}
Expand All @@ -109,7 +111,7 @@ end

ncases(counterfactual_values, treatments_cases) = sum(counterfactual_values .== treatments_cases)

function indicator_fns::StatisticalIATE)
function indicator_fns::StatisticalAIE)
N = length.treatment_values)
key_vals = Pair[]
treatments_cases = Tuple(case_control.case for case_control values.treatment_values))
Expand Down Expand Up @@ -233,7 +235,7 @@ unique_treatment_values(dataset, colnames) =
"""
Generated from transitive treatment switches to create independent estimands.
"""
get_treatment_settings(::Union{typeof(ATE), typeof(IATE)}, treatments_unique_values)=
get_treatment_settings(::Union{typeof(ATE), typeof(AIE)}, treatments_unique_values)=
sort(OrderedDict(key => collect(zip(uniquevaluess[1:end-1], uniquevaluess[2:end])) for (key, uniquevaluess) in pairs(treatments_unique_values)))

get_treatment_settings(::typeof(CM), treatments_unique_values) = sort(OrderedDict(pairs(treatments_unique_values)))
Expand Down Expand Up @@ -304,7 +306,7 @@ end

"""
factorialEstimand(
constructor::Union{typeof(CM), typeof(ATE), typeof(IATE)},
constructor::Union{typeof(CM), typeof(ATE), typeof(AIE)},
treatments, outcome;
confounders=nothing,
dataset=nothing,
Expand All @@ -314,9 +316,9 @@ end
verbosity=1
)
Generates a factorial `JointEstimand` with components of type `constructor` (CM, ATE, IATE).
Generates a factorial `JointEstimand` with components of type `constructor` (CM, ATE, AIE).
For the ATE and the IATE, the generated components are restricted to the Cartesian Product of single treatment levels transitions.
For the ATE and the AIE, the generated components are restricted to the Cartesian Product of single treatment levels transitions.
For example, consider two treatment variables T₁ and T₂ each taking three possible values (0, 1, 2).
For each treatment variable, the single treatment levels transitions are defined by (0 → 1, 1 → 2).
Then, the Cartesian Product of these transitions is taken, resulting in a 2 x 2 = 4 dimensional joint estimand:
Expand All @@ -332,7 +334,7 @@ A `JointEstimand` with causal or statistical components.
# Args
- `constructor`: CM, ATE or IATE.
- `constructor`: CM, ATE or AIE.
- `treatments`: An AbstractDictionary/NamedTuple of treatment levels (e.g. `(T=(0, 1, 2),)`) or a treatment iterator, then a dataset must be provided to infer the levels from it.
- `outcome`: The outcome variable.
- `confounders=nothing`: The generated components will inherit these confounding variables. If `nothing`, causal estimands are generated.
Expand All @@ -353,7 +355,7 @@ factorialEstimand(ATE, (T₁ = (0, 1), T₂=(0, 1, 2)), :Y₁)
- An Average Interaction Effect with statistical components:
```@example
factorial(IATE, (T₁ = (0, 1, 2), T₂=(0, 1, 2)), :Y₁, confounders=[:W₁, :W₂])
factorial(AIE, (T₁ = (0, 1, 2), T₂=(0, 1, 2)), :Y₁, confounders=[:W₁, :W₂])
```
- With a dataset, the treatment levels can be infered and a positivity constraint enforced:
Expand All @@ -369,7 +371,7 @@ factorialEstimand(ATE, [:T₁, :T₂], :Y₁,
"""
function factorialEstimand(
constructor::Union{typeof(CM), typeof(ATE), typeof(IATE)},
constructor::Union{typeof(CM), typeof(ATE), typeof(AIE)},
treatments, outcome;
confounders=nothing,
dataset=nothing,
Expand All @@ -393,7 +395,7 @@ end

"""
factorialEstimands(
constructor::Union{typeof(ATE), typeof(IATE)},
constructor::Union{typeof(ATE), typeof(AIE)},
dataset, treatments, outcomes;
confounders=nothing,
outcome_extra_covariates=(),
Expand All @@ -404,7 +406,7 @@ factorialEstimands(
Generates a `JointEstimand` for each outcome in `outcomes`. See `factorialEstimand`.
"""
function factorialEstimands(
constructor::Union{typeof(CM), typeof(ATE), typeof(IATE)},
constructor::Union{typeof(CM), typeof(ATE), typeof(AIE)},
treatments, outcomes;
dataset=nothing,
confounders=nothing,
Expand Down Expand Up @@ -437,7 +439,7 @@ function factorialEstimands(
return estimands
end

joint_levels::StatisticalIATE) = Iterators.product(values.treatment_values)...)
joint_levels::StatisticalAIE) = Iterators.product(values.treatment_values)...)

joint_levels::StatisticalATE) =
(Tuple.treatment_values[T][c] for T keys.treatment_values)) for c in (:control, :case))
Expand Down
2 changes: 1 addition & 1 deletion src/estimands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ AbsentLevelError(treatment_name, val, levels) = ArgumentError(string(
Checks the case/control values defining the treatment contrast are present in the dataset levels.
Note: This method is for estimands like the ATE or IATE that have case/control treatment settings represented as
Note: This method is for estimands like the ATE or AIE that have case/control treatment settings represented as
`NamedTuple`.
"""
function check_treatment_settings(settings::NamedTuple, levels, treatment_name)
Expand Down
2 changes: 1 addition & 1 deletion test/adjustment.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using TMLE
CM(outcome=:Y₁, treatment_values=(T₁=1,)),
ATE(outcome=:Y₁, treatment_values=(T₁=(case=1, control=0),)),
ATE(outcome=:Y₁, treatment_values=(T₁=(case=1, control=0), T₂=(case=1, control=0))),
IATE(outcome=:Y₁, treatment_values=(T₁=(case=1, control=0), T₂=(case=1, control=0))),
AIE(outcome=:Y₁, treatment_values=(T₁=(case=1, control=0), T₂=(case=1, control=0))),
]
method = BackdoorAdjustment(outcome_extra_covariates=[:C])
statistical_estimands = [identify(method, estimand, scm) for estimand in causal_estimands]
Expand Down
10 changes: 5 additions & 5 deletions test/composition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,25 +162,25 @@ end
T₂ = categorical(T₂),
Y = Y
)
IATE= IATE(
AIE= AIE(
outcome = :Y,
treatment_values = (T₁=(case=2, control=1), T₂=(case=2, control=1)),
treatment_confounders = (T₁ = [:W], T₂ = [:W])
)
IATE= IATE(
AIE= AIE(
outcome = :Y,
treatment_values = (T₁=(case=3, control=1), T₂=(case=3, control=1)),
treatment_confounders = (T₁ = [:W], T₂ = [:W])
)
IATE= IATE(
AIE= AIE(
outcome = :Y,
treatment_values = (T₁=(case=3, control=2), T₂=(case=3, control=2)),
treatment_confounders = (T₁ = [:W], T₂ = [:W])
)
jointIATE = JointEstimand(IATE₁, IATE₂, IATE₃)
jointAIE = JointEstimand(AIE₁, AIE₂, AIE₃)

ose = OSE(models=TMLE.default_models(G=LogisticClassifier(), Q_continuous=LinearRegressor()))
jointEstimate, _ = ose(jointIATE, dataset, verbosity=0)
jointEstimate, _ = ose(jointAIE, dataset, verbosity=0)

testres = significance_test(jointEstimate)
@test testres. estimate(jointEstimate)
Expand Down
4 changes: 2 additions & 2 deletions test/configuration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end
yamlfilename = mktemp()[1]
jsonfilename = mktemp()[1]
estimands = [
IATE(
AIE(
outcome=:Y1,
treatment_values= (
T1 = (case = 1, control = 0),
Expand Down Expand Up @@ -81,7 +81,7 @@ end
jsonfilename = mktemp()[1]
# With a StaticSCM, some Causal estimands and an Adjustment Method
estimands = [
IATE(
AIE(
outcome=:Y1,
treatment_values= (
T1 = (case = 1, control = 0),
Expand Down
2 changes: 1 addition & 1 deletion test/counterfactual_mean_based/3points_interactions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ end

@testset "Test 3-points interactions" begin
dataset, Ψ₀ = dataset_scm_and_truth(;n=1000)
Ψ = IATE(
Ψ = AIE(
outcome = :Y,
treatment_values = (
T₁=(case=true, control=false),
Expand Down
4 changes: 2 additions & 2 deletions test/counterfactual_mean_based/clever_covariate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ end
end

@testset "Test clever_covariate_and_weights: 2 treatments" begin
Ψ = IATE(
Ψ = AIE(
outcome = :Y,
treatment_values=(
T₁=(case=1, control=0),
Expand Down Expand Up @@ -90,7 +90,7 @@ end

@testset "Test compute_offset, clever_covariate_and_weights: 3 treatments" begin
## Third case: 3 Treatment variables
Ψ = IATE(
Ψ = AIE(
outcome =:Y,
treatment_values=(
T₁=(case="a", control="b"),
Expand Down
Loading

0 comments on commit 5de94f6

Please sign in to comment.