salbalkus / CausalTables.jl

A new type of Table to store and simulate data for causal inference in Julia.
https://salbalkus.github.io/CausalTables.jl/
MIT License
7 stars 0 forks source link

Allow arbitrary assignments in DGP #16

Closed salbalkus closed 3 months ago

salbalkus commented 8 months ago

Sometimes we might want to assign a static variable in a DGP and use it later because it encapsulates a long line of code, i.e.

@dgp(
        L1 ~ Exponential(1),
        L2 ~ Poisson(3),
        L3 ~ Beta(3, 2),
        L4 ~ DiscreteUniform(-3, 2),
        μ = (@. 0.01 * exp(:L1 + :L2 + :L3 + :L4 + 10) + 0.5),
        A ~ (@. truncated.(Normal(:μ, 1), μ - 2, μ + 2)),
        Y ~ (@. Normal(:A + 0.01 * :L1 + 0.1 * (:L2 + :L3 + :L4), 1))
    );

The dgp macro might be modified to support this.