{'fraction_non_alphanumeric': 0.037122730488092434, 'fraction_numerical': 0.010934921009195945, 'mean_word_length': 4.324623352165725, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Estimating heterogeneous treatment effects in nonstationary time series with state-space models

Randomized trials and observational studies, more often than not, run over a certain period of time. The treatment effect evolves during this period which provides crucial insights into the treatment response and the long-term effects. Many conventional methods for estimating treatment effects are limited to the i.i.d. setting and are not suited for inferring the time dynamics of the treatment effect. The time series encountered in these settings are highly informative but often nonstationary due to the changing effects of treatment. This increases the difficulty, since stationarity, a common assumption in time series analysis, cannot be reasonably assumed. Another challenge is the heterogeneity of the treatment effect when the treatment affects units differently. The task of estimating heterogeneous treatment effects from nonstationary and, in particular, interventional time series is highly relevant but has remained unexplored yet. We propose Causal Transfer, a method which combines regression to adjust for confounding with time series modelling to learn the effect of the treatment and how it evolves over time. Causal Transfer does not assume the data to be stationary and can be applied to randomized trials and observational studies in which treatment is confounded. Causal Transfer adjusts the effect for possible confounders and transfers the learned effect to other time series and, thereby, estimates various forms of treatment effects, such as the average treatment effect (ATE) or the conditional average treatment effect (CATE). By learning the time dynamics of the effect, Causal Transfer can also predict the treatment effect for unobserved future time points and determine the long-term consequences of treatment.


Introduction
Many types of experiments run over a period of time. For example, phase 1 clinical trials typically span several months while online experiments for measuring advertising effectiveness last several weeks. The treatment effect continuously evolves during the duration of the experiment. It might strengthen or weaken over time. This provides important information about the response to treatment. The treatment response and the value of the long-term effect, in particular, are critical for whether an experiment is successful. For example, advertising campaigns whose effectiveness last over a duration of time are preferable to campaigns whose effectiveness drop to 0 quickly. In order to predict long-term effects, one has to learn the time dynamics of the treatment effect. This is not an easy task since common time series assumptions like stationarity are not satisfied in the presence of interventions. Common strategies for analysing experimental panel data include analysing the data of every time point in the experiment in separation using an i.i.d. method, e.g., imputation [13], or by aggregating the experimental units and applying a time series method to the aggregated data, e.g., Causal Impact [3]. The first approach, while easy to implement, treats every time point as a separate experiment and does not pool information over time. The latter sacrifices information by combining the experimental units into a single unit. We propose novel methodology for estimating (average and heterogeneous) treatment effects from experiments which span multiple time points. Our method, Causal Transfer, makes use of all data from the entire experiment and neither requires data aggregation over time nor over units. We demonstrate this on simulated data and on real data from geo experiments in Section 3.
General setting. We first describe the general setting before specializing to potentially nonstationary and multivariate time series. Suppose that we observe d units. For each unit i, there exists a pair of outcomes (Y i (0), Y i (1)) under treatment and under control. Let T denote the binary treatment indicator and Y i = Y i (T i ) the observed outcome of unit i. The observed outcome is equal to Y i (1) if the unit is assigned to treatment and Y i (0) otherwise. We assume that there is no interference between units, i.e., the SUTVA assumption [28]. The measure reported most often from experiments is the average treatment effect (ATE) defined as The ATE implicitly assumes that the units are drawn from an underlying distribution of a large population. In some cases, the units might not be representative of such a population, e.g., when the units are selected. A more appropriate measure under these circumstances is the sample average treatment effect (SATE) (0)). The SATE is simply the treatment effect on the study units and it avoids assumptions on distributions [2]. If the treatment effect should be transferable to other units, however, the ATE is arguably more suited than the SATE. The SATE will converge against the ATE in the large sample limit if the units are, in fact, independent, reflective of a population, and the first moments of the potential outcomes exist.
When treatment affects units differently, the conditional average treatment effect (CATE) is of special interest: which captures the heterogeneity of the treatment effect as a function of some covariates X i . Obviously, the ATE is the expectation of the CATE: Moreover, the randomization assumption can be weakened substantially when integrating out the CATE to obtain the ATE, if the covariates X i are "well chosen" as discussed below. In many situations, the treatment T cannot be randomized due to ethical reasons and is endogenous. In this case, it is not sufficient to solely compare the difference of the means between the treatment and the control group. In order to identify the treatment effect, we require unconfoundedness, which is weaker than randomization. We assume that the treatment is randomized conditional on some covariates X i , that is: We can then infer the ATE as follows: where the assumption in (1) is used for the second equality and the last equality follows by the definition of a potential outcome when conditioned on the treatment. The formula (2) is also well known in structural equation modelling and often referred to as Pearl's backdoor adjustment formula [21]. In this framework, if X i blocks all backdoor paths from the treatment T i to the response Y i , the adjustment formula (2) is valid. A well-known example is when X i is the set of parental variables of T i in the graph corresponding to the underlying structural equation model. The choice of the set of covariates X i is in general non-trivial and requires domain knowledge. Nonetheless, time order often helps to simplify this problem since causes precede their effects.
Time series setting. Equation (2) requires the fitting of a regression function. In time series, we only observe one sequence of observations per stochastic process. To make inferences feasible, one either assumes redundancy in terms of stationarity or a parametric model for nonstationary settings. As soon as we intervene on a time series, it changes the distribution of the time series. Therefore, interventions typically break the stationarity of a time series. It goes without saying that many time series are not even stationary before an intervention takes place. For this reason, we focus on the latter approach and adopt the highly-established framework of state-space models for estimating dynamic regression functions [30]. Such state-space models share some properties, which make them well-suited for the task of causal effect estimation as they can deal with nonstationarity and missing observations. Causal inference is a missing data problem at its core. We develop a novel state-space model and corresponding methodology that estimates heterogeneous causal effects from potentially nonstationary time series. Our method, which we call Causal Transfer, is able to learn the effect of an intervention, transfer this effect to other time series and, thereby, estimate (causal) treatment effects in the form of population, sample, or heterogeneous effects. The state-space model further learns how the treatment effect evolves over time and is able to predict treatment effects for (unobserved) future time points.
We illustrate the idea with an example. Suppose we run a simple experiment on two units (both being a time series). Unit 1 is assigned to treatment and unit 2 to control. We observe the outcomes in Figures 1a and 1b. During the treatment or post-intervention period, we are only able to observe the outcomes under treatment for unit 1 and under control for unit 2. To predict the counterfactuals, we can learn the intervention from the observed outcomes through a state-space model. The learned effect can be transferred from unit 1 (Figure 1c) to unit 2 ( Figure 1d). With both the observed and predicted outcomes, one can estimate the average treatment effect (Figure 1e), relative treatment effects (Figure 1f), or any other function of the outcomes. We note that in this simple example with only one treated unit the transferred effect from unit 1 to 2 is equal to the estimated effect on unit 1. Once more treated units are available, one can learn an effect function and transfer unit-specific treatment effects depending on each unit's covariate values. Naturally, the estimated average treatment effects also improve as more treated and control units become available. Instead of transferring the learned intervention to another unit, it is also possible to transfer in time to predict the effect of a hypothetical intervention at another time point under the assumption that the effect, which is possibly a function of covariates, is invariant under time shifts.

Related work and our contribution
A related method which uses state-space models for causal effect estimation is Causal Impact [3]. Causal Impact infers the counterfactual of a treated univariate time series, that is, its outcome under no interventions. For this purpose, it requires a control time series: a covariate which is predictive of the time series of interest but not affected by treatment itself. Causal Impact learns the relationship between the response time series and the control time series by fitting a dynamic regression model during the pre-period. Causal Impact assumes that the learned relationship between the control and the response time series is stable over time. By doing so, Causal Impact is able to predict the counterfactual of the response time series for the treatment period. The treatment effect is estimated by subtracting the observed time series by the predicted counterfactual time series.
A major difference between Causal Impact and our method, Causal Transfer, is that the former is restricted to counterfactuals of a treated time series. It cannot learn the intervention and predict the counterfactual of control time series. In particular, Causal Transfer has an advantage in that it is able to predict future treatment effects, for which no data points have been observed. This is not feasible with Causal Impact since it requires the data of the treated time series to compute the effect. In many situations, not every unit can be treated due to ethical or economic reasons. In these cases,   Figure 1a shows the observed outcomes for unit 1 and Figure 1b for unit 2. Unit 1 is treated while unit 2 is not. The treatment period (or postintervention period) starts in February and is shown after the dashed line. During the pre-period in January, neither unit 1 nor unit 2 is treated. We learn the intervention from the observed outcomes through a state-space model. Consequently, we remove the learned effect from unit 1 in Figure 1c and transfer it to unit 2 in Figure 1d. By comparing the outcomes in Figures 1c and 1d, we are able to estimate the average treatment effect (Figure 1e) and the average relative treatment effect ( Figure 1f). We note that in this example the transferred effect is equal to the estimated effect on unit 1. Once more treated units become available, the transferred effect will be unit-specific and depend on the units' covariate values.
Causal Impact might not be able to estimate the effect or the estimate is biased since it is based on treated units alone, which might not be reflective of the control units. In the causal inference literature, this is referred to as the "treatment effect on the treated". Causal Transfer, on the other hand, is able to predict the counterfactual of both treated and untreated units as soon as it has seen the intervention on at least one treated unit. It adjusts the treatment effect for confounding. Therefore, it leads to less biased estimates of the treatment effects. Causal Impact further requires the response time series to be univariate. Multivariate time series have to be aggregated cross-sectionally to estimate average treatment effects. Causal Impact cannot estimate heterogenous effects, such as the CATE, without making further assumptions.
Marginal integration [19] is another related method for causal effect estimation. The main difference is that the regression function in Equation (2) is nonparametric and estimated with kernel regression before integrating out the adjustment set. Marginal integration can consistently estimate the ATE with optimal one-dimensional nonparametric convergence rate n −2/5 for continuous treatment variables [19]. The price to be paid for such a general result is that it requires strict stationarity for the estimation of the smooth regression function and is, therefore, restricted to observational time series. The theoretical guarantees hold for estimands which are functions of E[Y | do(T = t)] for some t in the support of T , such as the ATE. It does not support the estimation of prediction intervals. In principle, marginal integration can be extended to estimate sample average treatment effects or heterogenous effects. The theoretical guarantees, however, may not carry over as the estimation of the latter is severely exposed to the curse of dimensionality. Marginal integration is capable of predicting future effects but only up to the maximum time distance present in the data and assuming stationarity.
In econometrics, popular methods for causal inference with panel data include fixed-effects and first-difference models [10]. These models can control for selection biases due to time-invariant hidden confounders, but they also eliminate the effect of time-invariant observed variables. More recently, hybrid models were proposed that combine fixed with random effects to include the effect of time-invariant observables, for example [25]. These models assume that the unobserved time trend in the treatment group is equal to the observed time trend in the control group.
Causal Transfer estimates average or heterogeneous effects (or any other function of the potential outcomes) and their prediction intervals from potentially nonstationary, interventional data assuming no latent confounding. It does not differentiate between time-varying or time-invariant covariates while allowing the units to have individual time trends (see Section 2.2.1). Causal Transfer can be applied to randomized trials or observational studies. This makes our method widely applicable to many real-world scenarios. Causal Transfer fits a dynamic regression model to the data. Even though the regression model is linear, our method is robust for the ATE against misspecification (see Section 2.3). Lastly, Causal Transfer is able to inform us about unseen future effects, which provides crucial information when deciding whether a treatment is successful in the long run.
2 Causal effect estimation in nonstationary time series
In practice, we never observe the entire table but only one type of outcome per unit: either Y (0) or Y (1). Therefore, the estimation of causal effects involves predicting the missing outcomes. A naive approach for imputing the missing outcomes is to fit separate linear regression models of the observed outcomes against the treatment indicator Y t ∼ T to each time point t. We then predict the missing outcomes from the fitted regression models. This step is especially easy for the simple linear regression Y t ∼ T . It means that, at each time point, we impute the missing treated outcomes by the average over the observed treated units and the missing control outcomes by the average over the observed control units. The resulting table with both observed and imputed outcomes becomes:  With the completed table, we can proceed as before for estimating the ATE or any other function of the outcomes. For example, the estimate of the ATE now equals ((5+5+4+6)−(3+5+4+4))/4 = 1 for t = 1 and ((6 + 6 + 6 + 6) − (4 + 2 + 3 + 3))/4 = 3 for t = 2. To make the predictions more meaningful, one can include predictive covariates in the regression model.
The above naive approach does not incorporate time dependence and only works well for reasonably large numbers of units. We sketch how to impute the missing outcomes with state-space models instead. We replace the simple linear regression model by a dynamic regression model: where u t denotes the observation noise and v t , w t denote the process noise. This is a special case of a linear state-space model where the Kalman filter can be used. The first equation is the socalled measurement equation. The second and third equation are the so-called state equations. The measurement equation contains the regression model, while the state equations describe the time evolution of the regression coefficients. In this example, the states follow random walks. We predict the missing outcomes of Table 2 through the dynamic regression model in Table 4.  Table 4: Predicted outcomes using dynamic regression.
The estimated ATE using the Kalman filter estimates is (21 − 15)/4 = 1.5 for time point 1 and (23 − 13)/4 = 2.5 for time point 2. One advantage of the Kalman filter is that it pools information over time while learning the time dynamics of the treatment effect. It makes use of the underlying smoothness between time points in an experiment. For example, if the study units respond favourably to treatment on one day, it is unlikely that this will change drastically on the following day. The variance of the noise terms in the state equations can serve as smoothness conditions on the regression coefficients and, thereby, on the estimated effects. The separate regression models further emerge as a special case of the dynamic regression model by setting the AR coefficients of the state equations to 0. Having learned the time dynamics, the Kalman filter also predicts unseen future effects. This is not possible with separate regression models for each time point. In the following Section, we will outline the imputation scheme with state-space models in general.

State-space models for heterogeneous treatment effects
Causal Transfer combines regression with time series models into a flexible framework for causal effect estimation. Many modelling choices are possible. For example, one can choose linear dynamic regression models (possibly with interactions or fixed/random effects) or nonlinear models. Linear models can be fitted with the Kalman filter. Instead of the Kalman filter, one can use robust filters [9] [20] or nonlinear filters, such as the unscented Kalman filter [15] or the particle filter [7] to accommodate nonlinear models, non-Gaussian noise distributions, or outliers. A general description of the algorithm is given in Algorithm 1.

Algorithm 1 Causal Transfer
Input Dynamic regression model, data of observed outcomes and covariates. Output Estimated prediction intervals and treatment effects for every time point. 2: Apply a state-space method, e.g., the Kalman filter to estimate the states. 3: Estimate the treatment effect either from the states or by imputing the missing outcomes. 4: Estimate prediction intervals from the posterior distribution or through resampling methods.
We focus on linear models since they are robust against misspecification for the estimation of the ATE (see Section 2.3) and give examples of such models for the estimation of average and heterogenous effects. We consider a data set with n ∈ N time points and d ∈ N units. The Kalman filter is a well-known method for a linear state-space model. It consists of a measurement and a state equation: for t = 1, . . . , n. The measurements X t = (X 1,t , . . . , X d,t ) and the states θ t = (θ 1,t , . . . , θ m,t ) with m ∈ N are multivariate and F t , G t are d × m and m × m matrices respectively. The noise terms are independent of each other and normally distributed according to v t ∼ N (0, V t ) and w t ∼ N (0, W t ) with V t ∈ R d×d and W t ∈ R m×m . We assume that only the measurements (X t ) n t=1 of the measurement equation (3) are observable but not the states (θ t ) n t=1 . Therefore, our knowledge of the states comes from the measurements of (X t ) n t=1 and the state equation (4) alone. The measurements given the states (X t | θ t ) n t=1 are mutually independent. The Gaussian assumption for the noise terms is made for simplicity in Section 2.5. In fact, the Kalman filter is optimal if the noise terms are Gaussian and provides consistent estimates of the states while minimizing the mean-squared error. If the noise is not Gaussian, it is still the optimal linear estimator (although nonlinear methods might perform better).
The working model. We now switch the notation from Y i (0) and Y i (1) in Section 1 to a d-dim. response variable X t = (X 1,t , . . . , X d,t ) with potential outcomes X i,t (0) and X i,t (1) for each unit i = 1, . . . , d. For the purpose of estimating causal effects, we suggest a dynamic regression model. For example, Here, The noise terms w t , u t are jointly normally distributed with arbitrary (but constant) diagonal covariance matrices W t ≡ W . The noise terms u t , v t , and w t are independent of each other for all t = 1, . . . , n.
The variable T is the treatment indicator, i.e., T i = 1 for every unit i that is assigned to treatment and 0 otherwise. The treatment T can also be understood as being continuous dose values, i.e., T ∈ R + 0 . We assume that T remains fixed over time implying that a whole time series unit i is either treated (T i = 1) or untreated (T i = 0). It is possible to replace T by a time varying indicator T t . A model with a time-varying T t will be introduced in Section 2.2.1.
The covariates in Equation (5) only serve as examples. We assume that the covariates that appear in heterogeneous treatment effects are unaffected by treatment and render T i and (X i,t (0), X i,t (1)) independent if conditioned on. The variables X pre , Z t , g represent different types of such covariates. The variable X i,pre is a pre-period covariate, e.g., the value of unit i before the treatment begins. Intuitively, it makes sense that the treatment effect is in relation to the levels of the pre-period covariate. Therefore, an interaction term T X pre between the treatment indicator and the pre-period covariate can be included in the model. If the data indicates no such interaction, it can be omitted. The variable Z t represents a contemporaneous, time-varying covariate, which is predictive of the outcome X t but not affected by treatment itself. The term g is an optional factor with two levels indicating group membership. A factor with more than two levels can be accommodated with multiple dummy variables. Instead of fixed effects, one can also include random effects which are useful for cluster randomized trials. Of course, there can be more or less covariates of each type to achieve unconfoundedness as in (1) or more accurate approximation of heterogeneous treatment effects. For example, using more than one contemporaneous covariate per unit results in matrices for Z t at each t. Alternatively, there could be no covariates at all. In fact, if T is already randomized, no covariates are needed for estimating the ATE. In the simplest case of no covariates and c 1 = 1, the model reduces to the one in Section 2.1. If there is a large set of covariates C i,t = (X i,pre , Z i,t , g i , . . .), one can regress on the propensity score e(C i,t ) instead of all covariates since the propensity score satisfies (X i,t (0), X i,t (1)) ⊥ T i | e(C i,t ) as well.
In structural equation modelling, causal structures are represented as directed acyclic graphs. Possible graphs that lead to conditional randomization as in (1) are: The ATE of T on X t can be identified by regressing on an adjustment set. When there are no hidden variables, Pearl's backdoor criterion [21] is sufficient for finding a valid adjustment set. The criterion requires that all backdoor paths between T and X t are blocked by the adjustment set. For both graphs a) and b), a valid adjustment set is {X pre , Z t , g}. In graph a), {X pre , Z t , g} blocks all backdoor paths. The only backdoor path in graph b) is T ← X pre → X t . Although the adjustment set for b) only needs X pre , including Z t can help to improve efficiency and including g does not lead to inconsistency and can be of interest for heterogeneous effects.
An example. We are interested in the effect of tax penalties on car producers. In the above model, we can choose X i,t as the sales of a car manufacturer i from country g i . The treatment T is an increase in taxation due to tax penalties. The indicator T i is set to 1 if a company i is subject to the tax increase and 0 otherwise. Whether or not and how much a company is treated depends on the country g of unit i. The pre-period covariate X i,pre is the sales of company i before the onset of the tax increase. A covariate Z i,t , that is predictive of the sales but assumed to be unaffected by treatment could be the inflation rate or the GDP of country g i .
The evolution of the regression coefficients (β j,t , µ j,t ) j=0,1,2 is modelled as random walks or autoregressive processes. The parameters c j let µ j,t grow to infinity, or to remain of order O(1) over time, depending on whether the absolute value of c j is larger or equal to 1, or smaller than 1. One can add optional trend terms α = (α 1 , α 2 , α 3 ) and δ = (δ 1 , δ 2 , δ 3 ) to the random walks such that The constants α and δ modify the baselines of the trends of β t and µ t . The terms α and δ can also be time-varying α t and δ t as in local linear trend models. Furthermore, the model can be extended to capture the seasonality of the data by including higher-lagged terms in the state equations [3]. The above equations can, of course, be exchanged in favor of other equations if these are better suited.
Equation (5) is the measurement equation. Equations (6) and (7) are the state equations. The equations can be easily rewritten into the form needed for the Kalman filter: Regression estimators are known to be sensitive towards differences in covariate distributions between the treatment and the control group. If there is a lack of overlap between the covariate values, it could be beneficial to combine the dynamic regression model (5) with matching (e.g., [12]), blocking (e.g., [27]), or weighting (e.g., [26]). These methods can help to balance the covariate values. For example, one can match units with similar covariate values or propensity scores and apply our method to the matched data set.
A further remark concerns the identifiability of model (5). If T ≡ 0, one cannot possibly say anything about the effect of an intervention in the absence of having seen any, without making further assumptions. If d = 1 and T ≡ 1, the states are not identifiable since some of the predictors are perfectly collinear. The states only become identifiable once there is at least one treated and one control unit or, alternatively, if there is a pre-period in addition to the treatment period as outlined in Section 2.2.1. Since our goal is to estimate average and heterogeneous treatment effects, we will assume in the remainder of the manuscript to have observed at least one treated and one control unit.

Model extension for unit-specific states
One can extend the previous model in a way that allows each unit to have its own set of regression parameters. The observational part is then individual to each unit while the treatment parameters µ t are shared across units. In state-space form this can be written as: For every unit i, the corresponding state equations are We assume that v t ∼ N (0, V ) with V = diag(σ 2 1 , . . . , σ 2 d ) and that w t = (w 0,1,t , . . . , w 1,d,t ) and u t are jointly normally distributed with diagonal covariance matrix W . The noise terms u t , v t , and w t are independent of each other for all t = 1, . . . , n. This model has a time-varying treatment indicator T i,t and requires a pre-period for identifiability. It makes use of data from the pre-period and the treatment period and can also be fitted to a single treated unit (by removing the interaction terms T t X pre and T t g). Its advantage is that it allows each unit to evolve individually while the treatment effect X i,t (1)−X i,t (0) = µ 0,t +µ 1,t X i,pre +µ 2,t g i is still a transferable function of the covariate values of all units. This model extension, however, increases the number of unknown variance parameters (d variance parameters for v t ) which need to be estimated and potentially the risk of overfitting. In the following empirical sections, we will use the simpler dynamic regression model (5) instead.

Robustness against model misspecification
We argue that a misspecified (dynamic) regression model is not problematic when aiming to estimate the ATE, while it has a (negative) effect for the CATE. For simplicity, we present the argument in the notation of Section 1 without time series.
The potential outcomes are denoted by Y (1) and Y (0): we dropped the index i of the units here. We assume that the treatment assignment is randomized conditional on the covariates X as in (1). From formula (2), we know that the ATE can be inferred by . Assume now that we have misspecified the regression functions m T (·) for T ∈ {0, 1}. The misspecified function is assumed to be of the form The partial derivative with respect to µ T then leads to This implies that if we integrate out X in the misspecified model, we obtain , where the last inequality follows by (1). Thus, even when we have misspecified the regression functions m T (·) with a parametric model, the ATE can be consistently inferred. The empirical results in Section 3 confirm this.
Obviously, when m T (·) is misspecified, the heterogeneous treatment effect will be misspecified: it is only when averaging out X as in the ATE that the misspecification has no effect on the inference.

Robustness against outliers
Real data sets often contain outliers. The Kalman filter is sensitive towards outliers. Manual inspection of the data and removal of outliers is cumbersome. To guard against the influence of outliers, one can replace the Kalman filter with a robust filter in Causal Transfer. Robust filters in the literature include filters that minimize a robust loss function, e.g., [9], [5] and [18] and filters that learn weights for each observation and assign less weights to outliers, e.g., [1] and [29]. One way to implement a filter that minimizes a robust loss is to use the equivalence between the Kalman filter and least squares. Suppose the model is linear and of the general form: The estimating equations of the Kalman filter can then be rewritten into a sequence of equivalent least squares problems: The covariance Σ t is blockdiagonal with diagonal elements (R t , V t ). The matrix R t is equal to R t = G t C t−1 G T t + W t and the vector m t is the solution to the above least squares problem at time point t − 1. M-estimation can now be carried out on the equivalent least square problems. In practice, this is achieved by applying iterated reweighted least squares.
Instead of robust filters, one can combine nonlinear filters with Causal Transfer, such as the particle filter (also known sequential Monte Carlo methods). Nonlinear filters are beneficial if the state or the measurement equation contain nonlinearities or the noise is non-Gaussian, albeit at the price of higher computational cost.

Imputation with state-space models
We now discuss the Kalman filter version of the algorithm in greater detail. Before describing the steps, we will briefly outline how inferences are done with the Kalman filter. This is by no means exhaustive and we refer to [23] for more details.
Kalman filter. As before, we consider the model: The precise form of each element can be customized. Two proposals are given in Section 2.2. At time point 0, we assume that the distribution of the states are known with θ 0 ∼ N (m 0 , C 0 ). This is our starting point. At each time point t, one can propagate the distribution of the states according to the state equation (4). The resulting distribution is the one-step-ahead predictive distribution Similarly, one can compute the one-step-ahead predictive distribution of the measurements X t | X 1,...,t−1 according to the measurement equation (3), which is N (f t , Q t ) with f t = F t a t and Q t = F t R t F t + V t . The one-stepahead predictive distribution can be combined with the likelihood of the next observation X t | θ t for obtaining the filtering distribution of θ t | X 1,...,t using Bayes theorem: p(θ t | X 1,...,t ) = p(θ t | X 1,...,t−1 )p(X t | θ t )/p(X t | X 1,...,t−1 ) .

The filtering distribution of
The forecast error is e t = X t − f t . Intuitively, this step can be understood as a correction. The predicted distributions according to the state-space model are corrected for the latest observation. The weight of the correction term R t F t Q −1 t is referred to as the Kalman gain matrix. It depends on W t and V t through R t and Q t . If the error variance of the predicted states R t is small, the Kalman gain is small giving the correction term little weight and m t ≈ a t . If, on the other hand, the error variance of the measurement equation V t is small, t X t and more weight is given to the most recent observation X t . The choice of the Kalman gain as R t F t Q −1 t is optimal in terms of minimizing the mean-squared error of the forecast m t for θ t .
The filtering distribution of θ t | X 1,...,t only make use of the observations up to time point t. In retrospect, it is often desirable to estimate the distributions with all available data, i.e., the smoothing distribution of θ t | X 1,...,n . The smoothing distributions can be estimated recursively and backwards in time starting from the filtering distribution of θ n | X 1,...,n . If θ t+1 | X 1,...,n ∼ N (s t+1 , S t+1 ), the smoothing distribution of θ t | X 1,...,n for t = 1, . . . , n − 1 is N (s t , S t ) with The smoothing recursions can be derived from p(θ t | X 1,...,n ) = p(θ t+1 | X 1,...,n )p(θ t | θ t+1 , X 1,...,n )dθ t+1 . Intuitively, they can be understood as adding the information that is gained from the time points t + 1, . . . , n, which is not included in the filtering distributions.
In many situations, the parameters in the state-space model are not fully known. For example, the noise covariance matrices V t and W t or the parameters in G t may be unknown and have to be estimated from data. In these cases, one can use the maximum-likelihood estimation (MLE) for inferring the unknown parameters. Let ψ denote the unknown parameters. The distribution of X 1,...,n | ψ can be factorized into p(X 1,...,n | ψ) = n t=1 p(X t | X 1,...,t−1 , ψ). Each term in this product can be recognized as the one-step-ahead predictive distribution of X t | X 1,...,t−1 , ψ. From before, we know that the terms are equal to N (f t , Q t ). Therefore, one can rewrite the log-likelihood as This expression depends on ψ implicitly through the terms f t and Q t . Maximizing the log-likelihood or minimizing the negative log-likelihood with respect to ψ yields the MLE estimate of ψ. For computing the MLE, one can utilize the function dlmMLE from the R-package dlm [22]. This function builds the likelihood of the Kalman filter as a function of ψ and parses this expression to the function optim for optimization. A word of caution is necessary here. The likelihood function of the Kalman filter can exhibit many local minima. Therefore, it is advised to try different starting values for the MLE routine and to compare the resulting estimates before proceeding with further steps. The MLE in conjunction with the Kalman filter has been shown to be consistent and asymptotically normal for stationary and nonstationary but asymptotically identifiable models [24]. Chang, Miller, and Park [6] have proven its consistency and asymptotic mixed normality for nonstationary models that involve integrated time series. Although, to the best of our knowledge, there is no asymptotic theory for the MLE in general nonstationary models, the Kalman filter with ML estimated parameters is still regarded to work well. Some examples are reviewed by Kim, Nelson, et al. [17].
Causal Transfer. We now turn to two versions of Causal Transfer for predicting population and sample treatment effects. For illustration purposes, we include examples for model (5).
Sample version This version consists of the following steps. We first estimate the unknown parameters with MLE if needed, such as the covariance terms and the constants c 0 , c 1 , c 2 . We then plug in the estimated parameters into the state-space model. For all time points, we estimate the smoothing distribution N (s t , S t ) of the states by iterating the smoothing recursions (10). Given the smoothing distribution, we estimate the distribution N (f t ,Q t ) of the missing outcomes through f t =F t s t andQ t =F t S tF t + V t . The matrixF t contains the covariates of the counterfactuals. This implies thatF t is the same as F t except for T being replaced byT = |T − 1|. We draw B set of samples (x from N (f t ,Q t ) to impute the missing outcomes. We estimate the estimand of interestτ t . For the SATE, the effect sample is given bŷ τ b=1 into prediction intervals and point estimates, e.g., by taking the percentiles and the average. A pseudo-code version is shown below in algorithm 2. One can also estimate other estimands than the SATE, e.g., relative treatment effects.
Causal Transfer naturally extends to the prediction of unseen future treatment effects. We denote the future time points by t = n + 1, . . . , n ahead . We predict the distribution of the states N (m t , C t ) for the time period of interest recursively starting from N (m n , C n ). N (m n , C n ) is the filtering distribution at t = n, which coincides with the smoothing distribution at this time point. The parameters of the distribution are updated according to m t = G t m t−1 and C t = G t C t−1 G t + W t for t = n + 1, . . . , n ahead . No correction step with the Kalman gain is needed since no observations  have been made. We draw the predicted outcomes of the time series from N (f t , Q t ) with f t = F t m t and Q t = F t C t F t + V t and the predicted outcomes of the counterfactual series from N (f t ,Q t ) with f t =F t m t andQ t =F t C tF t + V t . We then proceed with the same steps as before for obtaining the prediction intervals and the point estimates. Algorithm 3 contains the pseudo-code version.  (ii) Predict effect sampleτ Population version In linear models, the ATE is especially simple and can be read off directly from the model coefficients: µ 0,t + µ 1,t E[X pre ] + µ 2,t E[g]. This example illustrates that the ATE and other population treatment effects can be estimated directly from µ t without having to impute the missing potential outcomes. Hence, one can skip the steps 4-6 for population treatment effects, such as the ATE. Instead, one draws samples (s b=1 directly from the smoothing distribution of the states N (s t , S t ) to estimate the effect samples (τ 2,t g i ). This is equivalent to replacing all outcomes by the expected outcomes. Suppose we sample the states s (b) t from N (s t , S t ). We replace the observed outcomes by the expected outcomes f and the missing outcomes by the expected outcomesf can be summarized into prediction intervals as before. The ATE point estimateτ t can be estimated directly from s t , e.g.,τ t = 1 d d i=1 (s 0,t +s 1,t X i,pre +s 2,t g i ). The population version of Causal Transfer is shown in algorithm 4. Algorithm 4 is computationally faster than algorithm 2 and accelerates computation time by roughly a factor 3. Both versions can be accelerated by parallelization of the sampling process or by sequential processing of the data points [8].
Heterogeneous version Population treatment effects implicitly assume that the units in the study are reflective of a larger population with an underlying distribution function. Naturally, population treatment effects can be transferred to new units that did not take part in the study as  long as they arise from the same population. The individual effect for a new unit with covariates X pre and g is the CATE E[X t (1) − X t (0) | X pre , g]. To estimate the CATE with algorithm 4, one estimates the effect sample in step 6 of algorithm 4 asτ 2,t g and the effect in step 9 of algorithm 4 asτ t = s 0,t + s 1,t X pre + s 2,t g.
We can integrate X pre out if we are interested solely in the effects as a function of g since is the so-called marginal conditional average treatment effect (MCATE) [11]. The MCATE is useful for comparing treatment effects between groups of units with different values of g. The effect samples for the MCATE in step 6 can be estimated asτ 2,t ) for group 2 with g = 1. Here, d 0 denotes the number of units in the group with g = 0 and d 1 the number of units in the group g = 1. The effect samples can be summarized into prediction intervals within each group. In the same way, the effect in step 9 can be estimated asτ t,g=0 = 1 d0 i;gi=0 (s 0,t + s 1,t X i,pre ) and τ t,g=1 = 1 d1 i;gi=1 (s 0,t + s 1,t X i,pre + s 2,t ) for each group respectively. The samples of the effect differences between the groups can be estimated conveniently from the effect samplesτ t,g=1 . The estimated average effect difference is equal toτ t,∆g =τ t,g=0 −τ t,g=1 .
The prediction of unseen future population treatment effects (Algorithm 5) is as simple as for sample treatment effects.

Empirical results
We assessed the empirical properties of Causal Transfer in simulations. We further compared its performance with two reference methods: Bayesian imputation and Causal Impact. Bayesian imputation is considered to be a standard method for inferring causal effects from cross-sectional data [13]. Causal impact, like Causal Transfer, uses state-space models for causal effect estimation. The methods represent two common strategies for estimating causal effects in panel data: One approach is to analyse the data of every time point in the experiment separately with an i.i.d method, such as Bayesian imputation. Another is to aggregate the data over all experimental units and to analyse the resulting univariate time series instead. More details on the reference method are provided in Section A.
Here, we provide the empirical results for a variety of simulation set-ups. Each of the following sections contains the results for different kinds of estimands. We begin with a section on sample treatment effects on synthetic data. We then proceed to population and heterogenous effects. Thereafter, we consider treatment assignments with confounding. Experimental findings on real data are presented last.

Sample treatment effects
We simulated data points according to the following true and misspecified models: • Model 1 (correctly specified): The pre-period covariate X i,pre is drawn from the uniform distribution U(0, 1) for each unit i = 1, . . . , d. We partition the units into two groups and let the variable g indicate the group membership, i.e., g i = 0 for units of group 1 and g i = 1 for the units of group 2. For example, half of the units could originate from country A and half of the units from country B. It seems natural to use one covariate for the units from group 1, e.g., GDP of country A and another covariate for units from group 2, e.g., GDP from country B. Therefore, the timevarying covariate Z t = (Z 1,t , Z 1,t . . . , Z 2,t , Z 2,t ) is chosen to be identical for half of the units: , where m 1 is drawn from U(0, 1) and m 2 from U(−1, 0). The indicator T i is equal to 1 for treated units and 0 otherwise. The states are modelled as random walks with β 0 = (0.2, 0.6, 0.3) and µ 0 = (1, 0.5, 0.3). The states µ 0,t , µ 1,t , and µ 2,t do not decay at the same rate. In fact, µ 2,t does not decay implying that the long-term treatment effect is not equal to 0. The noise terms v i,t , w j,t , u j,t are independent of each other, centered, and normally distributed with standard deviations 0.1, 0.01, and 0.01 respectively.
• Model 2 (multiplicative effect): this model replaces the additive effect in model 1 by a multiplicative one. As before, we generate the observational part as X obs i,t = β 0,t + β 1,t X i,pre + β 2,t Z i,t + v i,t . Now instead of adding the treatment effect, we multiply the observational part by the treatment effect, i.e., X i,t = T i µ t X obs i,t . The multiplicative effect is modelled as µ t = 1.5 + (µ t−1 − 1.5)0.9 + u t = 0.15 + 0.9µ t−1 + u t with µ 0 = 2 and u t being normally distributed with standard deviation 0.01. This equation implies that the treatment effect gradually decays from 2 to 1.5 over time.
• Model 3 (AR model): we use an AR model instead of a regression model for the observational part of the time series.
The variable X pre is replaced by X obs t−1 to add the AR term. The term β 1 is constant in time because, otherwise, there would be an interaction between two states. The states β 0,t , β 2,t , µ 0,t , µ 1,t , and µ 2,t are generated as in model 1. The noise variables v i,t and ν i,t are independent of each other, centered, and normally distributed with standard deviation 0.1.
• Model 4 (unit-specific parameters): the observational part of the time series is individual to each unit: . Furthermore, we add a nonlinearity by replacing X pre with X 2 pre in the equation for X obs t . The remaining states µ 0,t , µ 1,t , and µ 2,t are generated as in model 1.
• Model 5 (nonlinear effect): we misspecify the treatment effect by replacing X pre with cos(X pre ) in Furthermore, the starting value µ i,0 is drawn with replacement from {0.9, 0.91, 0.92 . . . , 1.1} for each unit. This implies that the effect is unit-specific. Each state evolves according to with u i,t ∼ N (0, 0.01 2 ). Hence, the effect grows slightly over time. The states β 0,t , β 1,t , β 2,t and the noise v i,t are generated as in model 1.
Model 1 is correctly specified, while the remaining models are misspecified. For all models, we generated n = 300 data points for d = 20 units. 10 units were assigned to the treatment group (5 units with g = 0 and 5 units with g = 1) and the remaining 10 units to the control group. We ran Causal Transfer with the dynamic regression model X t ∼ Z t + X pre * T + T g on models 1, 3, and 4 and X t ∼ Z t + X pre * T on models 2, 5, and 6 and estimated the SATE 1 We summarized the MSE, the coverage and width of the 95%-prediction intervals over the 100 simulation runs in Table 5. Our method is further capable of predicting unseen "future" treatment effects, for which no data point has been observed yet. We predicted "future" effects for time points t = n + 1, n + 2, . . . , n + 100 and compared the "future" to the "past" effects for t = 1, . . . , n in Table 5. Example plots for one simulation run are shown in Figures 2a -4b.
The MSE of the estimated "past" effects and the width of its prediction intervals are smallest for the correctly specified model (model 1) although it is hard to compare between the different  Table 5: Comparison between "past" and "future" SATE effects in terms of MSE, coverage, and width of the 95%-prediction intervals. The values were computed separately for the "past" for which data is available and the "future", for which no outcomes have been observed yet. The results were averaged over 100 simulation runs and the respective time period, e.g., MSE past = 1 100 100 b=1 t ) 2 and MSE future = 1 100 100 b=1 t ) 2 with τ t being the true effect,τ t the estimated effect at time t, and n = 300. The "future" effects are predicted from the model trained on the data points from "past". models. The coverage for the "past" effects is close to the desired 95% on model 1. The coverage remains close to 95% on the multiplicative model 2 irrespective of misspecification. The coverage on the remaining models varies between 81 and 90 %. Some undercoverage has to be expected, since these models contain misspecifications and more variability than what is assumed by our method.
When comparing "past" to "future" effects, it is noticeable that the MSE and the width of the prediction intervals increase. Due to the width increase, the coverage is closer to the desired rate of 95% for the "future" effects than the "past" effects. Figure 2a, for example, shows how the prediction intervals increase in width over time. Intuitively it makes sense, as the last observation lies more distant in the past the estimates become increasingly uncertain. Since no outcomes are available for the estimation of "future" effects, all outcomes need to be estimated. This adds a source of variability. The parameters of the distributions are estimated by iterating the state equation (4) and the measurement equation (3) without the subsequent correction step with the Kalman gain. The MSE of the predicted SATE increases for "future" effects due to the lack of the correction step, which would have corrected the predicted towards the observed values. As a result, the predicted "future" effects are smoother than the "past" effects. The overall trend of the predicted "future" effects in Figures 2a -4b remains close to the truth.
Next, we compare Causal Transfer to Causal Impact and Bayesian imputation. Predictions of "future" effects cannot be made with Bayesian imputation nor Causal Impact. Therefore, we restrict the comparison to the "past" effects for t = 1, . . . , n. Causal Impact only accepts univariate time series. Therefore, we aggregated the time series cross-sectionally and used the aggregated series as input for Causal Impact. Causal Impact further requires a pre-period to learn the relationship between the response and the control time series in absence of any interventions. This relationship is then exploited to predict the counterfactuals. Therefore, we generated 2n data points for Causal Impact: n pre-period points, on which Causal Impact is trained, and n treatment points, for which predictions are made. We used the same predictors for Bayesian imputation and Causal Transfer.
We estimated the SATE with all methods. The results averaged over 100 simulations are shown in Table 6. The estimates are shown for one simulation run in Figures 2 -4.
Causal Transfer achieves the lowest MSE among the methods compared except on model 4. In addition, the coverage of Causal Transfer is closest to the desired rate of 95% except on model 4. Causal Impact produces the widest prediction intervals on all models but model 4 while its coverage rates are too low. Causal Impact performs best on model 4 but the results are not substantially better than for Causal Transfer. Bayesian imputation has, overall, the narrowest intervals but also the least coverage. It is likely that the coverage of Bayesian imputation will improve for a larger number of units than d = 20.
The computation time reflects the complexity of the methods. Causal Impact estimates a single univariate dynamic regression model. Bayesian imputation fits one regression model per time point, and Causal Transfer a multivariate dynamic regression model which accounts for time dependence. As a result, Causal Impact is faster than Causal Transfer and Bayesian imputation in our simulations. Causal Transfer can be accelerated by parallelization of the sampling process or by sequential processing of the data.  Table 6: Comparison between Causal Transfer (CT), Causal Impact (CI), and Bayesian imputation (BI) in terms of MSE, coverage and width of the 95%-prediction intervals, and CPU time consumption for the estimation of the SATE. The comparison is restricted to the "past" effects. The results were averaged over n = 300 time points and 100 simulation runs, e.g., MSE = 1 100 100 b=1 t ) 2 with τ t being the true andτ t the estimated effect at time t.  (Figure 2a and 2b) is able to predict "future" effects, which are shown after the dashed line. The prediction intervals for "future" effects are wider than for the past effects. The prediction intervals are also wider for model 2 than for model 1. Bayesian imputation (Figure 2e and 2f) has the narrowest and Causal Impact (Figure 2c and 2d) the widest intervals.   Figure 4: Example analysis plots for the SATE on models 5 and 6. Causal Transfer (Figure 4a and 4b) is able to predict "future" effects, which are shown after the dashed line. Bayesian imputation (Figure 4e and 4f) undercovers while Causal Impact (Figure 4c and 4d) estimates the widest intervals. The ground truth in these models is smoother than in models 1-4. Causal Transfer is able to adapt its smoothness to the data.

Population and heterogenous treatment effects
We now turn to the estimation of population and heterogenous effects. In many situations, we are interested in how the treatment effect varies across individuals. One could imagine that a new unit appears after a study concludes. The new unit is similar to the study units. What would the treatment effect for the new unit be if it would have taken part in the experiment? The treatment effect is individual to each unit through the dependence on its covariate values. To transfer the effect to the new unit, we learn the CATE = E[X t (1) − X t (0) | X pre , g] from the experiment and plug in the covariate values of the new unit. A related topic is the difference in average treatment effects between groups of individuals. For example, how does the efficacy of a drug differ for young and old patients or how do policy changes affect big and small companies? These questions also raise the issue of heterogeneous treatment effects. In the following, we restrict ourselves to a setting with a single factor g with levels 0 and 1. But more groups can be handled in the same manner. The average treatment effect for units is the marginal conditional average treatment effect (MCATE), since it can be derived by taking the iterated (conditional) expectation of the CATE. The difference in the average treatment effects between the groups is equal to MCATE ∆g = MCATE g=1 −MCATE g=0 .
We test Causal Transfer for the task of inferring and transferring heterogeneous effects. We simulated data from model 1 and estimated the CATE, the MCATE, and the ATE. For the CATE, we drew the covariate X pre of the new unit from the uniform distribution and set g to 0. The averaged results are shown in Table 8. The estimated heterogeneous effects are plotted for one simulation run in Figure 5. In addition, we compare Causal Transfer to Bayesian imputation in Table 7. Causal Transfer outperforms Bayesian imputation in all aspects compared. Causal Impact cannot estimate heterogenous effects since it requires univariate time series. It can, however, estimate the ATE. Causal Impact estimates for the ATE are shown in Section 3.3.
The prediction of "future" effects is more uncertain than the prediction of the"past" effects since outcomes have yet to be observed. This uncertainty is reflected in wider intervals in Figures 5a-5e. The width and the MSE increase the most for the MCATE with g = 1 or ∆ g . Surprisingly, the width and the MSE for the prediction of the MCATE for g = 0 are less affected by the additional uncertainty. This could be because for g = 0, algorithm 4 does not need to draw samples of the state µ 2,t .   Table 8: Comparison between "past" and "future" heterogeneous effects in model 1. The results were averaged over 100 simulation runs and the respective time period. The desired coverage is 95%. The "future" effects are predicted from the model trained on the data points from the "past".

Confounded treatment assignment
In the previous simulations, every unit had the same probability for being allocated to treatment. We now switch to confounded treatment assignments in which the probability of receiving the treatment depends on the units' covariate values: • Assignment 1: five units with g = 1 and five units with g = 0 are randomly assigned to treatment. The remaining units are assigned to the control group.
• Assignment 2: nine units with g = 1 and one unit with g = 0 are randomly assigned to treatment. The remaining units are assigned to the control group.
• Assignment 3: one unit with g = 1 and nine units with g = 0 are randomly assigned to treatment. The remaining units are assigned to the control group.
The units are divided into two strata with g = 0 and g = 1. Stratified sampling is proportionally allocated in the first set-up and disproportionately allocated in the second and third set-up.
We estimated the ATE and the SATE with Causal Transfer and the reference methods under the different assignment mechanisms. The results are shown in Table 9. Causal Transfer is clearly the most stable across the assignment mechanisms for both the ATE and the SATE. The MSE, coverage and width of the prediction intervals are not affected much by the confounding. When moving from proportional allocation (assignment 1) to disproportionate allocation (assignments 2 and 3), the MSE and the width increase by approximately 2-3 times for Bayesian imputation while the coverage is too low. The coverage drops by up to 50% when switching from assignment 1 to assignments 2 and 3 for Causal Impact. The reason for the undercoverage seems to be that Causal Impact does not adjust the treatment effect for possible confounders. It simply takes the difference between the observed treated time series and the predicted control time series while neglecting the possible dependence on confounding variables. Bayesian imputation adjusts the treatment for confounding. However, it is not sufficiently powerful when only a few units per strata is assigned to treatment. For example, only one treated observation from the strata with g = 1 is available per time point in assignment 3. Causal Transfer is much less affected by this issue since it pools the data over time and makes the observations from other time points available instead.
Furthermore, we predicted "future" effects with Causal Transfer under the different treatment assignments and compared the results to the "past" effects in Table 10. As before, the MSE and the width of the prediction intervals increase when predicting "future" as opposed to "past" effects since no outcomes are observed yet. The results are, as a whole, stable across different assignment mechanisms.  (Figures 5a, 5c, and 5e) is able to predict "future" effects, which are shown after the dashed line. Causal Transfer produces smoother estimates and narrower intervals than Bayesian imputation (Figures 5b, 5d, and 5f) by pooling information over time.   Table 10: Comparison between "past" and "future" effects under confounded treatment assignments in model 1. The results were averaged over 100 simulation runs and the respective time period. The desired coverage is 95%. The "future" effects are predicted from the model trained on the data points from "past".

Real data
Geo experiments divide markets into non-overlapping regions, so called geos, and use these geos as the experimental units. Treatment is randomly applied across the geos to minimize contamination. In the context of online marketing, the treatment can be, e.g., an ad campaign. The advantages of geo experiments are that they protect the privacy of the users and that they are straightforward to set up. Geo experiments are challenging to analyse, though, because of the relatively small number of available geos. The geos also tend to be highly heterogeneous which increases the difficulty further.
We analysed publicly available data from a geo experiment [16] [14]. The time series consists of sales from 100 geos from January 5 to March 15 2015. The treatment, an ad campaign, is applied between February 16 and March 15. The experiment randomly assigned 50% of the geos to treatment. We preprocessed the data with the square root transform to correct for skewness. We further excluded 16 geos which had missing values from the analysis. We applied Causal Transfer with the dynamic regression model X t = β 0,t + β 1,t X pre + µ t T to the experimental data. The response variable X t denotes the sales at time point t. The covariate X pre is constructed from the average sales over the week from January 5 to January 11 for the period before the treatment starts and from February 9 to February 15 for the treatment period. The states β 0,t and β 1,t were modelled as random walks and µ t as a local linear trend. The observations were given weights of 1/ X pre to adjust for heteroskedasticity. The resulting estimates are shown in Figure 6a. The prediction intervals of Causal Transfer include zero in the pre-period, as expected, since no treatment is applied. It also seems plausible that the treatment effect grows slightly during the treatment period since it takes some time for users to see the ad and to decide to respond to it. We also applied the reference methods, Bayesian Imputation and Causal Impact, under the same conditions, i.e., the same information is given to both methods (in aggregated form for Causal Impact since it requires univariate time series). Results are shown in Figure 6b and 6a. The point estimates of Bayesian Imputation and Causal Transfer are more variable (also in the pre-period where the effect is known to be neutral). Compared to Causal Impact, the prediction intervals of Causal Transfer are tighter. The prediction intervals of Causal Impact even include 0 on certain days during the treatment period. This implies that we cannot detect a significant effect on these days. Bayesian imputation returns tight intervals but they are not neutral in the pre-period which indicates undercoverage.
In addition to the treatment effect, Causal Transfer can be used to estimate the so-called "incremental return on ad spend" (iROAS) if the marketing cost is available. The iROAS is of interest in marketing. It is defined as the incremental sales divided by the incremental ad spend. To estimate the iROAS, one can regress the sales against the marketing cost, i.e., X t = β 0,t + β 1,t X pre,t + η t cost t . The regression coefficient η t corresponds to the iROAS at time point t. The iROAS cannot be estimated with Causal Impact directly. Causal Impact requires fitting two separate models, one for the sales and one for the cost, and computes the ratio between the estimated incremental sales and the estimated incremental cost to obtain the iROAS.
On another note, geos are typically made up of smaller constituents, e.g., stores. If finer data than geos is available, one can analyse these finer units instead of geos to increase precision. This corresponds to a cluster randomized trial in which the geos are equivalent to the clusters. To account for the additional correlations between the units within a geo, one can combine a hierarchical model or the cluster bootstrap [4] with Causal Transfer.  Figure 6: The estimated ATE and 90%-prediction intervals for a geo experiment [16]. The treatment period started on February 16 and ended on March 15 2015. The true effect should be close to 0 in the pre-period between January 12 and February 15 since no treatment is applied. The prediction intervals of Causal Transfer and Causal Impact correctly cover 0 during the pre-period. However, the prediction intervals of Causal Impact also cover 0 on some days of the treatment period. Bayesian imputation, on the other hand, gives tight intervals but is not neutral in the pre-period indicating undercoverage. The effect estimates all exhibit weakly patterns. Causal Transfer can predict future effects which are shown after the dashed line in Figure 6d. The prediction quickly grows uncertain over time. This is not surprising because the pre-period covariate loses predictive power over time.
The pre-period covariate does not help to capture seasonality either. If time-varying or contemporaneous covariates are available, the predictions are likely to improve. Note, that the axis of the Causal Impact plots are wider in comparison to the other plots.

Conclusions
We suggest new methodology and a new estimation algorithm for heterogeneous treatment effects in time series. Our method, which we call Causal Transfer, applies state-space models to infer the treatment effect from experiments and observational studies. We note that especially interventional time series exhibit nonstationarities. The underlying model of Causal Transfer can be customized to describe many structures, making it more appropriate for real-world applications than methods which require stationarity or complete randomization. Causal Transfer can estimate a variety of estimands in both forms of the population or sample version, e.g., the ATE, the SATE, the CATE, or the MCATE. Each of these estimands is useful for different purposes. The ATE is well-recognized in many fields, but the SATE is better suited when units are selected and not reflective of a population. The CATE, MCATE are helpful when treatment effects are heterogenous. Importantly, Causal Impact also provides prediction intervals for these effects.
Causal Transfer assumes a linear state-space model for fitting the intervention. In simulation studies, the model has proven to be quite robust against misspecifications. Theoretically, this can be justified for average treatment effects. Causal Transfer can further be combined with robust or nonlinear filters in the presence of outliers or non-Gaussian distributions. Causal Transfer outperformed the reference methods, Causal Impact and Bayesian imputation, in most of our simulations and leads to more meaningful results in a real data application. Our method complements the existing methods for a number of reasons. Methods for the i.i.d. setting, such as Bayesian imputation or difference in difference, performs well when many units are available. For smaller number of units, they are not sufficiently powered. Causal Transfer is able to increase power by pooling information over time. Time series methods, such as Causal Impact, on the other hand, are limited to predicting the counterfactual of a single treated time series, whereas our method predicts the counterfactual of treated and control time series and, thereby, estimates heterogeneous treatment effects. Lastly, Causal Transfer is able to provide information on future effects: long-term effects, in particular, are crucial for deciding whether a treatment was successful.   Figure 7a shows the predicted "future" effects after the dashed line.   Figure 9: Example analysis plots for the ATE and the SATE under (confounded) treatment assignment 3 in model 1. The true ATE and SATE effects are very similar since the units were drawn from a distribution. Causal Transfer (Figure 9a and 9b) is able to predict "future" effects, which are shown after the dashed line. Bayesian imputation (Figure 9c and 9d) and Causal Impact (Figure 9e and Figure 9f) both undercover and have wider intervals than Causal Transfer.