# Causal Inference vs. Outcome Maximization

Beside curiosity, the goal of causal inference is to use the inferred causal relationship for better outcomes in the future. Once we estimate $\mathbb{E}_G\left[ y | \mathrm{do}(a)\right]$ using RCT, we would simply choose the following action for all future subject:

[] \begin{align} \hat{a} = \arg\max_{a \in \mathcal{A}} \mathbb{E}_G\left[ y | \mathrm{do}(a)\right], \end{align} []

where $\mathcal{A}$ is a set of all possible actions. This approach has however one downside that we had to give an incorrect treatment (e.g. placebo) to many trial participants who lost their opportunities to have a better outcome (e.g. protection against the infectious disease.) Consider an RCT where subjects arrive and are tested serially, that is, one at a time. If $t$ subjects have participated in the RCT so far, we have

[] \begin{align} D = \left\{ (a_1, y_1), \ldots, (a_t, y_t) \right\}. \end{align} []

Based on $D$, we can estimate the outcome of each action by

[] \begin{align} \hat{y}_t(a) = \frac{\sum_{t'=1}^t \mathds{1}(a_{t'} = a) y_{t'}} {\sum_{t''=1}^N \mathds{1}(a_{t''} = a)}. \end{align} []

This estimate would be unbiased (correct on average), if every $a_{t'}$ was drawn from an action distribution that is independent of the covariate $x$ from an identical distribution $q(a)$.[Notes 1] More generally, the bias (the degree of incorrectness) would be proportional to

[] \begin{align} \epsilon_{\leq t-1} = \frac{1}{t} \sum_{t'=1}^t \mathds{1}(a_{t'} \text{ was drawn independently of } x_{t'}). \end{align} []

If $\epsilon_{\leq t-1} = 1$, the estimate is unbiased, corresponding to causal inference. If $\epsilon_{\leq t-1} = 0$, what we have is not interventional but conditional. Assuming $\epsilon_t \gg 0$ and $t \gg 1$, we have a reasonable causal estimate of the outcome $y$ given each action $a$. Then, in order to maximize the outcome of the next subject ($x_{t+1}$), we want to assign them to an action sampled from the following Boltzmann distribution:

[] \begin{align} q_t(a) = \frac{\exp\left( \frac{1}{\beta_t} \hat{y}_t(a) \right)} {\sum_{a' \in \mathcal{A}} \exp\left( \frac{1}{\beta_t} \hat{y}_t(a') \right)}, \end{align} []

where $\beta_t \in [0, \infty)$ is a temperature parameter. When $\beta_t \to \infty$ (a high temperature), this is equivalent to sampling the action $a_{t+1}$ from a uniform distribution, which implies that we do not trust the causal estimates of the outcomes, perhaps due to small $t$. On the other hand, when $\beta_t \to 0$ (a low temperature), the best-outcome action would be selected, as

[] \begin{align} q_t(a) =_{\beta \to \infty} \begin{cases} 1, &\text{ if } \hat{y}(a) = \max_{a'} \hat{y}_t(a') \\ 0, &\text{ otherwise} \end{cases} \end{align} []

assuming there is a unique action that leads to the best outcome. In this case, we are fully trusting our causal estimates of the outcomes and simply choose the best action accordingly, which corresponds to outcome maximization. We now combine these two in order to make a trade off between causal inference and outcome maximization. At time $t$, we sample the action $a_t$ for a new participant from

[] \begin{align} \label{eq:bandit_policy} q_t(a) = \epsilon_t \frac{1}{|\mathcal{A}|} + (1-\epsilon_t) \frac{\exp\left( \frac{1}{\beta_t} \hat{y}_t(a) \right)} {\sum_{a' \in \mathcal{A}} \exp\left( \frac{1}{\beta_t} \hat{y}_t(a') \right)}, \end{align} []

where $\epsilon_t \in [0, 1]$ and $|\mathcal{A}|$ is the number of all possible actions. We can sample from this mixture distribution by

• Sample $e_t \in \left\{0,1\right\}$ from a Bernoulli distribution of mean $\epsilon_t$.
• Check $e_t$
• If $e_t=1$, we uniformly choose $a_t$ at random.
• If $e_t=0$, we sample $a_t$ proportionally to $\hat{y}(a)$.

As we continue the RCT according to this assignment policy, we assign participants increasingly more to actions with better outcomes, because our causal estimate gets better over time. We however ensure that participants are randomly assigned to actions at a reasonable rate of $\epsilon_t$, in order to estimate the causal quantity rather than the statistical quantity. It is common to start with a larger $\epsilon_t \approx 1$ and gradually anneal it toward $0$, as we want to ensure we quickly estimate the correct causal effect early on. It is also usual to start with a large $\beta_t \geq 1$ and anneal it toward $0$, as the early estimate of the causal effect is often not trustworthy. When the first component (the uniform distribution) is selected, we say that we are exploring, and otherwise, we say we are exploiting. $e_t$ is a hyperparameter that allows us to compromise between exploration and exploitation, while $\beta_t$ is how we express our belief in the current estimate of the causal effect. This whole procedure is a variant of EXP-3, which stands for the exponential-weight algorithm for exploration and exploitation~[1], that is used to solve the multi-armed bandit problem. However, with an appropriate choice of $\epsilon_t$ and $\beta_t$, we obtain as a special case RCT that can estimate the causal effect of the action on the outcome. For instance, we can use the following schedules of these two hyperparameters:

[] \begin{align} \epsilon_t = \beta_t = \begin{cases} 1,& \text{ if } t \lt T \\ 0,& \text{ if } t \geq T \end{cases} \end{align} []

with a larger $T \gg 1$. We can however choose smoother schedulers for $\epsilon_t$ and $\beta_t$ in order to make a better compromise between causal inference and outcome maximization, in order to avoid assigning too many subjects to a placebo (that is, ineffective) group. The choice of $\epsilon_t$ and $\beta_t$ also affects the bias-variance trade-off. Although this is out of the scope of this course, it is easy to guess that higher $\epsilon_t$ and higher $\beta_t$ lead to a higher variance but a lower bias, and vice versa.

A never-ending trial. A major assumption that must be satisfied for RCT is the stationarity. Both the causal distribution $p^*(y|a,x)$ and the covariate distribution $p^*(x)$ must be stationary in that they do not change throughout the trial as well as after the trial. Especially when these distributions drift after the trial, that is, after running the trial with $T$ participants, our causal estimate as well as the decision based on it will become less accurate. We see such instances often in the real world. For instance, as viruses mutate, the effectiveness of vaccination wanes over time, although the very same vaccine was found to be effective by an earlier RCT. When the underlying conditional distributions are all stationary, we do not need to keep the entire set of collected data points in order to compute the approximate causal effect, because

[] \begin{align} \hat{y}_t(a) = \frac{\sum_{t'=1}^t \mathds{1}(a_{t'} = a) y_{t'}} {\sum_{t''=1}^N \mathds{1}(a_{t''} = a)} = \frac{\sum_{t'=1}^{t-1} \mathds{1}(a_{t'} = a)}{\sum_{t'=1}^t \mathds{1}(a_{t'} = a)} \hat{y}_{t-1}(a) + \frac{ \mathds{1}(a_{t} = a)}{\sum_{t'=1}^t \mathds{1}(a_{t'} = a)} y_{t}. \end{align} []

In other words, we can just keep a single scalar $\hat{y}_t(a)$ for each action to maintain the causal effect over time. We can tweak this recursive formula to cope with slow-drifting underlying distributions by emphasizing recent data points much more so than older data points. This can be implemented with exponential moving average,[Notes 2] as follows:

[] \begin{align} \hat{y}_t(a) = \begin{cases} \eta \hat{y}_{t-1}(a) + (1-\eta) y_t,& \text{ if }a_t = a \\ \hat{y}_{t-1}(a),& \text{ if }a_t \neq a \end{cases} \end{align} []

where $\eta \in [0, 1)$. As $\eta \to 0$, we consider an increasingly smaller window into the past and do not trust what we have seen happen given a particular action. On the other hand, when $\eta \to 1$, we do not trust what happens now but rather what we already know about the causal effect of an action $a$ should be. By keeping track of the causal effect with exponential moving average, we can continuously run the trial. When doing so, we have to be careful in choosing the schedules of $\epsilon_t$ and $\beta_t$. Unlike before, $\epsilon_t$ should not be monotonically annealed toward $0$, as earlier exploration may not be useful later when the underlying distributions drift. $\beta_t$ also should not be annealed toward $0$, as the estimate of the causal effect we have at any moment cannot be fully trusted due to the unanticipated drift of underlying distributions. It is thus reasonable to simply set both $\beta_t$ and $\epsilon_t$ to reasonably large constants.

Checking the bias. At time $t$, we have accumulated

[] \begin{align} D_t = \left\{ (e_1, a_1, y_1), \ldots, (e_t, a_t, y_t) \right\}, \end{align} []

where $e_{t'}$ indicates whether we explored ($1$) or exploited ($0$) at time $t'$. We can then get the unbiased estimate of the causal effect of $a$ on $y$ by only using the triplets $(e,a,y)$ for which $e=1$. That is,

[] \begin{align} \tilde{y}_t(a) = \frac{\sum_{t'=1}^t \mathds{1}(e_{t'} = 1) \mathds{1}(a_{t'} = a) y_{t'}} {\sum_{t''=1}^t \mathds{1}(e_{t''} = 1) \mathds{1}(a_{t''} = a) }. \end{align} []

This estimate is unbiased, unlike $\hat{y}(a)$ from EXP-3 above, since we only used the action-outcome pairs when the action was selected randomly from the same uniform distribution. Assuming a large $t$ (so as to minimize the impact of a high variance,) we can then compute the (noisy) bias of the causal effect estimated and used by EXP-3 above as

[] \begin{align} b_t = (\hat{y}_t(a) - \tilde{y}_t(a))^2. \end{align} []

Of course this estimate of the bias is noisy and especially so when $t$ is small, since the effective number of data points used to estimate $\tilde{y}_t$ is on average

[] \begin{align} \sum_{t'=1}^t \epsilon_{t'} \leq t. \end{align} []

## General references

Cho, Kyunghyun (2024). "A Brief Introduction to Causal Inference in Machine Learning". arXiv:2405.08793 [cs.LG].

## Notes

1. This is another constraint on RCT, that every subject must be assigned according to the same assignment policy $q(a)$.
2. ‘exponential-weight’ in EXP-3 comes from this choice.

## References

1. "The non-stationary stochastic multi-armed bandit problem" (2017). International Journal of Data Science and Analytics 3. Springer.