On Counterfactual Interventions in Vector Autoregressive Models ††thanks: This work was supported by the National Science Foundation under Awards 2021002 and 2212506.
Abstract
Counterfactual reasoning allows us to explore hypothetical scenarios in order to explain the impacts of our decisions. However, addressing such inquires is impossible without establishing the appropriate mathematical framework. In this work, we introduce the problem of counterfactual reasoning in the context of vector autoregressive (VAR) processes. We also formulate the inference of a causal model as a joint regression task where for inference we use both data with and without interventions. After learning the model, we exploit linearity of the VAR model to make exact predictions about the effects of counterfactual interventions. Furthermore, we quantify the total causal effects of past counterfactual interventions. The source code for this project is freely available at https://github.com/KurtButler/counterfactual_interventions.
Index Terms:
causal models, counterfactuals, interventions, time series, vector autoregressive modelsI Introduction
In many situations, we may be interested in “what-if” questions. As decisions in real life are rarely made with perfect knowledge of their effects, it is only natural that later one may question the optimality of their choices and ask how things would be if a different decision had been made. This process of reasoning about decisions and actions that contradict what actually occurred pertains to problems of counterfactual reasoning.
A counterfactual event is an event which does not agree with a particular outcome that was observed in a given experiment [1, p. 29]. For example, a student applying to a college might be rejected due to a low score on an entrance exam. A counterfactual question could then be “would this student have been accepted if their score were higher?” In asking this question, we are imagining a hypothetical scenario in which we modify the score of this student, and keep all other variables (i.e., the scores of all the other applicants) constant. In general, counterfactual questions may help us understand whether our actions are effective.
For the problem of detecting the presence of causal relationships and learning the graphical structure of a causal system, a large variety of approaches have been proposed, often arising from different fundamental principles [2, 3, 4, 5]. Many of these methods attempt to rely on entirely observational data, where the experimenter cannot intervene upon the system under study to probe into its cause and effect relationships. While it is sometimes possible to detect causalities without intervention, observational approaches often require strong assumptions that are difficult to verify empirically or are otherwise restrictive.For instance, identification of a linear causal model from only observations is ill-posed if the noises are Gaussian [6, pp.50-51]. Methods based on predictability, such as Granger causality [7], can deliver false positives when not all relevant variables are included in the model. Other methods may require strong assumptions; for example, convergent cross map** [8] requires the existence of a dynamical attractor, which is difficult to test on small data sets [9]. In comparison, when it is possible to perform interventions, causal inference becomes considerably simpler, with several standard algorithms [3],[10]. Under ideal conditions, when experiments can be carried out perfectly and there are no hidden processes, all causal relationships in system of variables can be detected with single-variable interventions [11].
To answer counterfactual questions, more information than just the direction of causalities is required: one must also have a functional model of how the effect is determined by all of its causes [1]. For the college student example, we would need to know the entrance exam scores of the other applicants to determine the functional model for acceptance and subsequently if the given student would be accepted, as their acceptance would depend on all of the scores.
In this work, we consider the counterfactual prediction problem: Given a particular realization of a causal system, i.e., a multivariate time series and a causal model that explains it, can we predict what we would have observed if a previous, hypothetical intervention occurred?
We present several contributions relevant to studying counterfactual events with time series. We introduce an approach to learning the causal structure of a system by leveraging multiple data sets with different interventions. We apply this approach to the setting of vector autoregressive (VAR) models. After learning the causal model, we address the problem of making counterfactual predictions. Due to linearity of the VAR model, we are able to make exact predictions without needing to estimate unobserved variables. Finally, we validate our approach using several examples.
II Problem Formulation
We consider the problem of modeling causal relationships from a multivariate time series . For each node and time instant , we assume that the value of is determined by a function of the values of the system at previous time steps, , up to some order , as well as a separate independent noise term . As a simple example, we examine the vector autoregressive (VAR) model:
(1) |
where the are matrices of linear coefficients, and , for some given noise covariance . The notation expresses the direction of causality, where we consider (1) as a causal generative process.
According to (1), the components of , , and exert causal influences on . It is traditional in causality to express these relationships in terms of a graph, although there are several options as to how this can be done. In Figure 1, we present one approach that treats each time instance as a separate vertex, with the purpose of understanding the temporal dependencies of the VAR model, which will later simplify the calculation and prediction of counterfactuals.
To answer counterfactual queries about a system, we must first have a structural causal model (SCM) of the system [1]. A SCM is a hypothesis about the generative process that created a data set. The SCM represents each variable in the system as a function of its parents, a subset of variables directly influencing a given variable, along with an exogenous noise variable. In this way, the VAR model in (1) can be interpreted as a SCM after we declare that the equation explicitly describes how the value of is determined.
Asserting that a VAR model is a causal model is a stronger statement than asserting it is a statistical model. A statistical model needs only to generate the correct joint probability distribution over the family of variables, but a causal model is a hypothesis about the generative process as it exists in reality. In the same way that multiple generative processes can represent the same probability distribution, there might be multiple SCMs that are compatible with a given data set. Additionally, different causal models will produce different answers to counterfactual questions, so care should be taken to learn the most accurate causal model before discussing counterfactuals. In the next section, we introduce interventions and how SCMs respond to them.
II-A Interventions
A major feature of causal models is that they are modularized, meaning that we may think of them as a set of individual components which can be changed or modified. In our example, each variable receives a value according to the formula
(2) |
where is the -th row of , and is the -th element of in (1). An intervention at node and time is a modification to the causal model which replaces the function that assigns a value to with a new one. For example, we may intervene by replacing the function in (2) with a new one:
(3) |
where are modified linear coefficients, is a signal injected by the experimenter, and is a parameter that may be used to control the level of noise. Under ideal conditions, the experimenter’s intervention perfectly controls the value of by tuning the parameters in (3) to achieve a desired effect.
In this paper, we assume that all interventions are able to perfectly control the value of the node intervened upon, so that satisfies (3) whenever an intervention on is being performed. While intervening on a node , it is assumed that the functions governing other nodes in the system remain unchanged, which is a form of modularity of the system. In real life, there might be some uncertainty in the values of and when the intervention is performed, due to imperfect experimental conditions. An intervention can be applied for a period of time, during which we can actively observe the behavior of the rest of the system, i.e., the unperturbed nodes. We illustrate this process visually in Figure 2.
Data that we record while performing an intervention are called interventional, contrasting with observational data that we record while not altering the system under study. While performing an experiment with multiple interventions, we allocate recorded data into separate data sets according to the type of intervention being applied (cf. Figure 2). In Section III-A, we introduce a method to leverage multiple data sets to improve estimation of over purely observational data. The caveat is that this approach is only possible when obtaining interventional data is feasible.
![Refer to caption](extracted/5696873/Figures/interventions_cropped.png)
.
II-B The problem of predicting counterfactuals
Having introduced SCMs and interventions, we may now formulate counterfactuals in our framework. In short, a counterfactual is a hypothetical intervention. It is not an intervention that occurred in reality, but rather one whose behavior we can predict, having already observed a realization of the system.
Now that the necessary causal background has been introduced, we can state the primary problem of this work. Consider an experiment in which we observe a multivariate signal until a certain time , and suppose that we have assumed a particular SCM for . Now assume we are interested in a hypothetical intervention that would have occurred in the past, and want to predict what we would have observed in this hypothetical scenario. That is,
(4) | |||
(5) |
where are the signals in the case that we performed a hypothetical intervention upon for some in the range , and for a fixed . Here we make an important assumption that all conditions of the experiment, such as the particular realization of the noise process , remains the same in both cases. This is necessary, because in considering the counterfactual problem, asserting that all other conditions were the same implies that the noise too, should have the same realization.
In general models, the values of need to be estimated before counterfactual analysis can be performed. However, this estimation is straightforward in any additive noise model since enters the formulas additively. In our approach, we exploit linearity of the system to circumvent the need to estimate at all because the influence of the noise will cancel out.
III Proposed Solution
Before making counterfactual predictions, it is essential to first learn the causal structure of the system. To learn the parameters of the causal model in a way that leverages both observational and interventional data, we propose a joint regression task that allows us to infer the parameters of each module shared across datasets. We make the tacit assumption that these interventions are ideal, and that the parameters of the model are unchanged when they are not related to the intervention. We now introduce some notation. If at time we perform an intervention to control the value of , then the time point should be allocated to a set of time indices . If no intervention was performed, then the index of is allocated to the index set . We assume that only one node can be intervened upon per time step , so whenever . We define
(6) |
to be the set of time indices of , where was not subject to intervention. It is permissible that some index sets may be empty, . In principle, these sets could be partitions of a single recording trial, or obtained from multiple recording trials, with no major modification to our approach.
III-A Causal structure learning
For clarity in presentation, we will first describe the case of one lag , and from there we extend to the multiple lag case.
SINGLE LAG
The goal is to learn the linear coefficient matrix of the true causal model jointly across datasets by minimizing the following objective,
(7) |
where the operation removes row from the matrix .
Using the identity , we can simplify this optimization task considerably. Recall that whenever we intervene on a particular variable, all other linear coefficients remain unchanged. Thus, the function that assigns a value to is given by
whenever , or equivalently, when . These considerations lead us to propose the following objective, which is equivalent to (7):
(8) |
where, again, is the -th row of .
The revised objective in (8) has multiple advantages. Firstly, it can be solved for each variable separately as a distinct subproblem. Secondly, it makes it clear that minimum mean squared estimate of can be obtained using classical methods. If we assume some level of sparsity in , then we can use LASSO[12], or regularization, to get a sparse estimate:
(9) |
where is a regularization parameter.
MULTIPLE LAGS
To generalize to the case in which , we only need to modify the approach slightly. Consider the model in (1). If we define
(10) |
and
(11) |
then we can express (1) as
(12) |
Now we can formulate a similar optimization task as before, giving us the multiple lag version of (7):
which can again be split into tractable sub-problems. Considering sparsity, the multiple lag version of (9) is given to be
(13) |
where is the -th row of . The use of sparsity constraints becomes increasingly relevant when considering multiple lags, since strongly autocorrelated signals can have multiple distinct models with similar predictive power [13].
III-B Estimation of total causal effects
We now consider the problem of estimating the effects of a past counterfactual intervention. Suppose that we have observed up until some time . For some , consider an intervention that modifies to take on a new value . If we define , then we can reason about the hypothetical intervention as an additive change in :
Since the VAR model is linear, the additive change in induces an additive change in all variables “downstream” from it in the graph. For example, if we move one step into the future, then changes according to
where is the -th unit vector in . We observe that the linear model coefficients in measure the sensitivity of to changes in , and can be interpreted as a measure of the strength of the causal relationship [14].
If we perform an intervention at time and attempt to predict its effect at time , we need to propagate the changes through the graph in Figure 1, that is, through each intermediate time step. When , the path in the graph from to is not unique, and the total sensitivity of to is given by a sum over all paths in the graph [15, 16]. Since the VAR model is time-invariant, the total sensitivity is a matrix which only depends upon . We refer to this matrix as a total causal effect matrix.
To compute the total causal effect matrix for the VAR model, we can exploit recursion. Suppose that . Any path from to must go through a node between and . As a result, the total causal effect decomposes according to the same rule:
(14) |
If , then a similar rule holds, but we define to be the identity matrix, and for any , since causation can only move forward in time.
IV Experiments
In this section, we demonstrate our approach to modeling counterfactuals with two examples. First, we demonstrate how joint regression can be leveraged to more accurately learn the causal model. Second, we explore an example in which we study the effects of a past intervention on future, forecasted events. The presented results are of single outcomes of the experiments.
![Refer to caption](extracted/5696873/Figures/exp2_lag2.png)
IV-A Learning causal models with joint regression
We simulated a time-series of length , and system dimension with lag . Each element in the matrix coefficients was generated as , for . We set about sparsity for each matrix. The dynamics were perturbed with Gaussian noise , where the covariance is a Toeplitz matrix with , , and otherwise. We intervened on the node within the interval and the node in the interval . For this example, we let the intervened nodes be driven by a sine wave, specifically , where , for in their respective time intervals. The rest of the nodes () were left unperturbed. We learned the coefficients in two ways: i) by using only the observational (unintervened data ), and ii) using intervened data as well - the proposed method. To insure a fair comparison, we opted to use the same number of data points for learning in both i) and ii), where in the case of i), of those points are the interventional dataset. With the current setup, the proposed method is at a slight disadvantage in regards to amount of data used, since we lose points for learning the coefficients for , . However, those same points of intervention allow us to better estimate the coefficients for .
In Figure 3, we show the true matrices , for , their estimate using only, and their estimate with the proposed method, i.e., using interventional data as well. We can see there is a drop in MSE when using the proposed method, which is also reflected visually in the heat maps. The effect becomes even more prominent when learning larger systems.
IV-B Predicting the effects of a counterfactual intervention
In this experiment, we consider the problem of predicting the effects of a counterfactual intervention in the past. Consider a multivariate time series of length and dimension . We assume that the causal model is given by a VAR model, (1), with , whose parameters are known from prior investigation. Let us consider a counterfactual situation in which, at times until the end of the experiment, the experimenter intervenes upon by driving the signal with a new signal, .
In Figure 4, we predict the effects of the counterfactual intervention on , as perceived by another variable . We plot the signal that we observed originally alongside its variant in an “alternate universe,” in which the counterfactual intervention is performed. For times , both the observed time series and the counterfactual one coincide, as no intervention has not occurred yet. For , we see the counterfactual intervention begin to make the two time series diverge due to the effects of the intervention. Again, the model is able to well anticipate the counterfactual universe.
![Refer to caption](extracted/5696873/Figures/counterfactual.png)
V Conclusion
In this work, we studied the problems of counterfactual reasoning and causal inference in the context of vector autoregressive models. By considering the system as modular and assigning separate functions to each variable, we can approach regression and model learning in a nonlinear manner. Learning of the causal model is a necessary requirement to reason about counterfactual interventions and other what-if scenarios. The analysis of counterfactuals for nonlinear settings is analogous to what we have presented here, although additional care must be taken to estimate unobserved variables like the noises. Future work involves understanding the interventions for improved learning of the studied system and combining counterfactual analysis with interventions to achieve desired outcomes. Other directions include extending the counterfactual analysis to nonlinear models and models where the functional relationships are unknown and need to be estimated.
References
- [1] J. Pearl, Causality. Cambridge University Press, 2009.
- [2] D. B. Rubin, “Estimating causal effects of treatments in randomized and nonrandomized studies.,” Journal of Educational Psychology, vol. 66, no. 5, p. 688, 1974.
- [3] P. Spirtes, C. N. Glymour, R. Scheines, and D. Heckerman, Causation, Prediction, and Search. MIT Press, 2000.
- [4] X. Zheng, B. Aragam, P. K. Ravikumar, and E. P. Xing, “DAGs with NO TEARS: Continuous optimization for structure learning,” Advances in Neural Information Processing Systems, vol. 31, 2018.
- [5] T. Schreiber, “Measuring information transfer,” Physical Review Letters, vol. 85, no. 2, p. 461, 2000.
- [6] J. Peters, D. Janzing, and B. Schölkopf, Elements of causal inference: foundations and learning algorithms. The MIT Press, 2017.
- [7] C. W. Granger, “Investigating causal relations by econometric models and cross-spectral methods,” Econometrica: Journal of the Econometric Society, pp. 424–438, 1969.
- [8] G. Sugihara, R. May, H. Ye, C.-h. Hsieh, E. Deyle, M. Fogarty, and S. Munch, “Detecting causality in complex ecosystems,” Science, vol. 338, no. 6106, pp. 496–500, 2012.
- [9] K. Butler, G. Feng, and P. M. Djurić, “On causal discovery with convergent cross map**,” IEEE Transactions on Signal Processing, vol. 71, pp. 2595–2607, 2023.
- [10] J. M. Ogarrio, P. Spirtes, and J. Ramsey, “A hybrid causal search algorithm for latent variable models,” in Conference on Probabilistic Graphical Models, pp. 368–379, PMLR, 2016.
- [11] F. Eberhardt, C. Glymour, and R. Scheines, “N-1 experiments suffice to determine the causal relations among N variables,” Innovations in Machine Learning: Theory and Applications, pp. 97–112, 2006.
- [12] R. Tibshirani, “Regression shrinkage and selection via the Lasso,” Journal of the Royal Statistical Society Series B: Statistical Methodology, vol. 58, no. 1, pp. 267–288, 1996.
- [13] C. Cui, P. Banelli, and P. M. Djurić, “Topology inference of directed graphs by gaussian processes with sparsity constraints,” IEEE Transactions on Signal Processing, 2024.
- [14] K. Butler, G. Feng, and P. M. Djurić, “A differential measure of the strength of causation,” IEEE Signal Processing Letters, vol. 29, pp. 2208–2212, 2022.
- [15] Y. Liu, C. Cui, D. Waxman, K. Butler, and P. M. Djurić, “Detecting confounders in multivariate time series using strength of causation,” in 2023 31st European Signal Processing Conference (EUSIPCO), pp. 1400–1404, IEEE, 2023.
- [16] S. Salehkaleybar, A. Ghassami, N. Kiyavash, and K. Zhang, “Learning linear non-Gaussian causal models in the presence of latent variables,” Journal of Machine Learning Research, vol. 21, no. 39, pp. 1–24, 2020.