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

Computing causal quantities across worlds is too clunky #80

Closed
eb8680 opened this issue Dec 28, 2022 · 1 comment
Closed

Computing causal quantities across worlds is too clunky #80

eb8680 opened this issue Dec 28, 2022 · 1 comment
Assignees
Labels

Comments

@eb8680
Copy link
Contributor

eb8680 commented Dec 28, 2022

Can we make it easier to select the correct subsets of batched causal variables to compute some cross-world estimand like a treatment effect? This question seems important enough to be addressed before an initial release.

Currently the API is really clunky and relies on unspecified behavior (the ordering of plate dimensions created by MultiWorldCounterfactual), as can be seen in e.g. the definition of ITE in the SLC example:

Y_cf[..., 1, 0, :, :] - Y_cf[..., 0, 1, :, :]

What kind of higher-level interface could we provide for specifying quantities like this that's less error-prone than indexing into the plate dimensions but more tightly scoped in its implementation than named indexing in Funsor?

One possibility: if we were to add an optional name keyword argument to the intervene primitive, we could define a named indexing operator select_world handled by MultiWorldCounterfactual:

@effectful(type="select_world")
def select_world(value: T, intervention_indices: Mapping[str, int], *, event_dim: int = 0) -> T:
    ...

Then an expression like the one above could be made unambiguous:

a = intervene(a, a_, name="a")
...
b = intervene(b, b_, name="b")
...
select_world(Y_cf, dict(a=0, b=1)) - select_world(Y_cf, dict(a=1, b=0))

Specifying names for intervention sites could be largely automated in practice by modifying the do handler to use the names of pyro.sample sites supplied to it by a user.

@eb8680
Copy link
Contributor Author

eb8680 commented Mar 17, 2023

Addressed by #97

@eb8680 eb8680 closed this as completed Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant