betaFeedback

WorksComputer Science

Robust Counterfactuals for Markov Decision Processes under Statistical and Causal Uncertainties

Abstract

Counterfactual reasoning (asking what would have happened, had a decision been different) is a powerful tool for identifying causes of failure and explaining the behaviour of AI systems in sequential decision-making tasks. In Markov Decision Processes (MDPs), two sources of uncertainty complicate counterfactual inference: statistical uncertainty in the MDP transitions when the MDP is estimated from trajectory data, and uncertainty about the unknown causal model, as there are multiple structural causal models (SCMs) compatible with each MDP. Existing work addresses these two challenges in isolation. We address both simultaneously by introducing a framework for partial counterfactual inference in MDPs that is robust to both statistical and causal uncertainty. Our approach provides: 1) closed-form analytical bounds for the counterfactual probabilities that are valid across all SCMs entailed by a given interval MDP (IMDP); 2) a method to compute minimal robust interventions to achieve a desired counterfactual outcome via pessimistic value iteration on the induced counterfactual IMDP. Since the latter is constructed using our analytical bounds, our approach remains efficient and scalable to realistic MDP environments. Experiments across multiple case studies demonstrate our method's robustness and practical utility for identifying minimal sets of actions that, if changed, would have led to improved outcomes.

Introduction

Markov Decision Processes (MDPs) are a fundamental model for describing sequential decision-making processes under uncertainty, including reinforcement learning (RL) problems. Counterfactual reasoning for MDPs is central to policy evaluation, explanation, and accountability. Given an observed MDP path, i.e., a state-action sequence, one may ask: Would a different sequence of actions have led to a different outcome? Such questions arise in numerous applications, such as generating counterfactual explanations [23, 29, 30], facilitating policy transfer [15], data augmentation with counterfactual paths [18, 28], as well as LLM counterfactuals [4, 25].

However, two distinct sources of uncertainty complicate counterfactual reasoning for MDPs. First, counterfactuals in MDPs are generally not point-identified: many structural causal models (SCMs) can be compatible with the MDP, each yielding different counterfactual outcomes. We call this causal uncertainty. Yet, many approaches assume a fixed SCM, typically a Gumbel-max SCM [2, 14, 15, 22, 29, 33], potentially leading to invalid counterfactual conclusions. Second, the transition probabilities of an MDP are often estimated from finite trajectory data. Yet, most counterfactual analyses treat these point estimates as precise probabilities, ignoring statistical uncertainty in the learned MDP.

Recent work by Lally et al. [17] addresses the causal uncertainty problem by bounding counterfactual probabilities across all SCMs consistent with the MDP. Also, there is a well-established line of research (e.g., [21, 26, 27]) on capturing statistical uncertainty by using uncertain MDPs, where each transition probability lies within a data-derived confidence set, most often an interval (yielding interval MDPs).

However, there is no work to date that addresses both kinds of uncertainty, even though both matter for identifying robust interventions and explanations. Consider a learned model for sepsis treatment. Suppose that, under a nominal transition estimate, changing the dosage at step tt prevents an adverse outcome. So we would conclude that action ata_t is a sufficient intervention to prevent that outcome, but only if the transition probabilities were precise. Since these are learned from data and subject to sampling variability, there could be alternative models supported by the data where the adverse outcome would have occurred regardless of the dosage at tt, i.e., where intervening on ata_t alone is not enough. Thus, we seek counterfactual interventions that are robust to statistical uncertainties, i.e., valid across all MDP models entailed by some data-derived confidence set. For a similar reason, since there are many SCM models compatible with an MDP, we want such interventions to be robust to causal uncertainty, because each SCM can yield different counterfactual probabilities and thus different counterfactual policies that would have led to the patient’s recovery.

In this paper, we develop a framework for robust counterfactual reasoning in uncertain MDPs. Our contributions span two main areas:

1) Counterfactual bounds for uncertain MDPs. We derive analytical bounds for the counterfactual transition probabilities of a given interval MDP (IMDP). Our bounds are robust to both sources of uncertainty in this setting: they are guaranteed to include the true (unknown) counterfactual probabilities for every MDP M\mathcal{M} entailed by the IMDP, and every SCM compatible with M\mathcal{M}. To achieve this, we build on the work of Lally et al. [17], who derived bounds on counterfactual probabilities for standard (certain) MDPs, and extend it – for the first time – to the uncertain MDP setting. Crucially, without our analytical characterisation, computing robust counterfactual probabilities becomes prohibitive, as it entails solving an optimisation problem with a number of constraints exponential in the size of the MDP [7, 31, 32]. Finally, we prove that our analytical bounds are exact (i.e., tight) in all but one case. For this remaining case, we provide conservative (i.e., sound) bounds that remain empirically efficient. As a contribution of independent interest, we further derive conservative bounds for the special (parametric) case of Gumbel-max causal models.

  1. Minimal robust counterfactual interventions. Building on these bounds, we define the notion of a minimal robust counterfactual intervention as an MDP policy that performs the smallest set of action changes to induce a desired counterfactual outcome across all the causal models induced by statistical and causal uncertainty. In our MDP setting, w.l.o.g., we define outcomes as constraints over the (counter)factual path’s expected return. Given an IMDP estimated from data and an observed path, to derive such robust interventions, our method first constructs a counterfactual IMDP by computing bounds for all its transitions; then, interventions are found as solutions to a robust value iteration procedure [20] modified so that its value function keeps track of the allowed number of action changes. Finally, we evaluate our approach on a variety of MDP environments to investigate sources of failure in suboptimal RL policies, demonstrating that our method remains accurate and robust to uncertainty in both the MDP transitions and the causal model.

Background

In this section, we outline the background connecting Markov Decision Processes (MDPs), structural causal models (SCMs), and counterfactual inference.

Markov Decision Processes

MDPs model sequential decision-making under uncertainty: at each time tt, an agent in state sts_t selects an action ata_t via a policy π\pi, transitions to st+1∼P(⋅∣st,at)s_{t+1} \sim P(\cdot\mid s_t, a_t), and receives reward R(st,at)R(s_t, a_t). Formally, an MDP is a tuple M=(S,A,P,PI,R)\mathcal{M} = (\mathcal{S}, \mathcal{A}, P, P_I, R), where S\mathcal{S} is the discrete state space, A\mathcal{A} the set of actions, P:(S×A)→Δ(S)P : (\mathcal{S} \times\mathcal{A}) \to\Delta(\mathcal{S}) the transition probability function, PI∈Δ(S)P_I \in\Delta(\mathcal{S}) the initial state distribution, and R:(S×A)→RR : (\mathcal{S} \times\mathcal{A}) \to\mathbb{R} the reward function.

A (deterministic) policy π\pi for M\mathcal{M} is a function π:S→A\pi: \mathcal{S} \to\mathcal{A}. A path τ\tau of M\mathcal{M} under policy π\pi is a sequence τ=(s0,a0,s1,a1,…,sT−1,aT−1,sT)\tau= (s_0, a_0, s_1, a_1, \ldots, s_{T-1}, a_{T-1}, s_T) where T=∣τ∣T = |\tau| is the path length, PI(s0)>0P_I(s_0) > 0, at=π(st)a_t = \pi(s_t) for all t=0,…,T−1t = 0, \ldots, T - 1, and P(st+1∣st,at)>0P(s_{t+1} \mid s_t, a_t) > 0 for all t=0,…,T−1t = 0, \ldots, T - 1.

While MDPs can model a wide range of real-world decision-making problems [8], it is often challenging to determine the transition probability function PP exactly. To address this, uncertain MDPs allow us to explicitly account for uncertainty in the transition dynamics. In particular, interval MDPs represent this uncertainty through lower and upper bounds on the transition probabilities.

Definition 2.1 (Interval MDP [6]). An Interval Markov Decision Process (IMDP) is a tuple MI=(S,A,PI,PI,R)\mathcal{M}_{\mathcal{I}} = (\mathcal{S}, \mathcal{A}, P_{\mathcal{I}}, P_I, R), where S\mathcal{S}, A\mathcal{A}, PIP_I, and RR are as in a standard MDP, and PIP_{\mathcal{I}} is an uncertain transition function: for all s,s′∈Ss, s' \in\mathcal{S} and a∈Aa \in\mathcal{A} there exist bounds 0≤PMILB(s′∣s,a)≤PMIUB(s′∣s,a)≤10 \leq P_{\mathcal{M}_{\mathcal{I}}}^{\mathrm{LB}}(s' \mid s, a) \leq P_{\mathcal{M}_{\mathcal{I}}}^{\mathrm{UB}}(s' \mid s, a) \leq1 such that PI(s′∣s,a)=[PMILB(s′∣s,a),PMIUB(s′∣s,a)]P_{\mathcal{I}}(s' \mid s, a) = [P_{\mathcal{M}_{\mathcal{I}}}^{\mathrm{LB}}(s' \mid s, a), P_{\mathcal{M}_{\mathcal{I}}}^{\mathrm{UB}}(s' \mid s, a)].

Counterfactual Inference

Structural causal models (SCMs) [12, 24] provide a mathematical framework for reasoning about causality and counterfactual inference. Formally, a SCM is a tuple C=(U,V,F,P(U))\mathcal{C} = (\mathcal{U}, \mathcal{V}, \mathcal{F}, P(\mathcal{U})), where

V\mathcal{V} is the set of endogenous (observed) variables, U\mathcal{U} is a set of exogenous (unobserved) variables, P(U)P(\mathcal{U}) is a joint distribution over each U∈UU \in\mathcal{U}, and F\mathcal{F} is a set of structural equations such that each fV∈Ff_V \in\mathcal{F} determines the value of variable V∈VV \in\mathcal{V} as a function of UV∈UU_V \in\mathcal{U} and of VV’s endogenous parents Pa⁡V⊆V\operatorname{Pa}_\mathcal{V} \subseteq\mathcal{V}. An intervention (denoted do(X=x)do(\mathbf{X} = \mathbf{x})) modifies the SCM by fixing one or more variables X⊆V\mathbf{X} \subseteq\mathcal{V} to specific values x\mathbf{x} and severing their dependence on their respective parents Pa⁡V\operatorname{Pa}_{\mathcal{V}} in the causal graph; combined with the original P(U)P(\mathcal{U}) this yields an interventional distribution over the remaining variables. Counterfactual inference follows the same procedure, except it infers a posterior P(U∣V)P(\mathcal{U} \mid\mathcal{V}) over the values of the exogenous variables associated with a given observation v\mathbf{v}, and then applies the intervention do(X=x)do(\mathbf{X} = \mathbf{x}) using P(U∣v)P(\mathcal{U} \mid\mathbf{v}) in place of P(U)P(\mathcal{U}), yielding a distribution over the counterfactual outcomes.

Counterfactual Inference in MDPs

An MDP can be represented as an SCM with the causal graph of Figure 1 and the following structural equations:

MDP causal graph

Figure 1. MDP causal graph. White nodes are the endogenous variables; grey nodes are the exogenous variables.

St+1=f(St,At,Ut);At=π(St);S0=fI(UI);Rt=fR(St,At).(1)\begin{aligned} S_{t+1} &= f(S_t, A_t, U_t); \quad A_t = \pi(S_t);\\ S_0 &= f_I(U_I); \quad R_t = f_R(S_t, A_t). \tag*{(1)} \end{aligned}

The exogenous variables UtU_t capture all sources of randomness in the MDP, rendering the structural equations deterministic (given UtU_t). In this setting, the interventional distribution P(St+1=s′∣do(At=a))=s′P(S_{t+1} = s' \mid do(A_t = a)) = s' corresponds to the MDP’s transition probabilities P(⋅∣s,a)P(\cdot\mid s, a) and observations are paths τ=(s0,a0,…,sT−1,aT−1,sT)\tau= (s_0, a_0, \ldots, s_{T-1}, a_{T-1}, s_T) of length TT.

Counterfactual inference is applied at the level of the individual timesteps: given the observed transition st,at→st+1s_t, a_t \to s_{t+1} at time tt, we first infer the posterior distribution over the exogenous variable UtU_t consistent with this observation, P(Ut∣St=st,At=at,St+1=st+1)P(U_t \mid S_t = s_t, A_t = a_t, S_{t+1} = s_{t+1}). We then use this posterior to evaluate the counterfactual probability of reaching outcome St+1=s~′S_{t+1} = \tilde{s}', had we been in state St=s~S_t = \tilde{s}, and instead performed action At=a~A_t = \tilde{a}. Formally, we define this counterfactual probability as P~t(s~′∣s~,a~)=P(St+1(St←s~,At←a~)=s~′∣St=st,At=at,St+1=st+1)\tilde{P}_t(\tilde{s}' \mid\tilde{s}, \tilde{a}) = P(S_{t+1}(S_{t \leftarrow\tilde{s}, A_t \leftarrow\tilde{a}}) = \tilde{s}' \mid S_t = s_t, A_t = a_t, S_{t+1} = s_{t+1}), where St+1(St←s~,At←a~)S_{t+1}(S_{t \leftarrow\tilde{s}, A_t \leftarrow\tilde{a}}) denotes variable St+1S_{t+1} in the SCM after the intervention St←s~S_t \leftarrow\tilde{s} and At←a~A_t \leftarrow\tilde{a}.

These single-timestep counterfactual probabilities can be combined across all timesteps to construct a non-stationary counterfactual MDP [29], allowing us to reason about counterfactual outcomes over an entire trajectory.

References

  1. [1]Alessandro Abate, Maria Prandini, John Lygeros, and Shankar Sastry. 2008. Probabilistic reachability and safety for controlled discrete time stochastic hybrid systems. Automatica 44, 11 (2008), 2724–2734. doi:10.1016/j.automatica.2008.03.027DOI
  2. [2]Nina L Corvelo Benz and Manuel Gomez Rodriguez. 2022. Counterfactual inference of second opinions. In Uncertainty in Artificial Intelligence. PMLR, 453–463.arxiv.org/abs/2203.08653
  3. [3]Lars Buesing, Theophane Weber, Yori Zwols, Sébastien Racanière, Arthur Guez, Jean-Baptiste Lespiau, and Nicolas Heess. 2019. Woulda, coulda, shoulda: Counterfactually-guided policy search. In International Conference on Learning Representations (ICLR).
  4. [4]Ivi Chatz, Nina Corvelo Benz, Eleni Straitouri, Stratis Tsirtsis, and Manuel Gomez Rodriguez. 2025. Counterfactual token generation in large language models. In Proceedings of the Fourth Conference on Causal Learning and Reasoning (Proceedings of Machine Learning Research, Vol. 275). PMLR, 1291–1315.
  5. [5]Charles J Clopper and Egon S Pearson. 1934. The use of confidence or fiducial limits illustrated in the case of the binomial. Biometrika 26, 4 (1934), 404–413.DOI
  6. [6]Rudi Coppola, Andrea Peruffo, Licio Romao, Alessandro Abate, and Manuel Mazo Jr. 2024. Data-driven interval MDP for robust control synthesis. arXiv preprint arXiv:2404.08344 (2024).
  7. [7]Guilherme Duarte, Noam Finkelstein, Dean Knox, Jonathan Mummolo, and Ilya Shpitser. 2024. An automated approach to causal inference in discrete settings. J. Amer. Statist. Assoc. 119, 547 (2024), 1778–1793. doi:10.1080/01621459.2023.2216909DOI
  8. [8]Eugene A Feinberg and Adam Schwartz. 2012. Handbook of Markov decision processes: methods and applications. Vol. 40. Springer Science & Business Media.
  9. [9]Robert Givan, Sonia Leach, and Thomas Dean. 2000. Bounded-parameter Markov decision processes. Artificial Intelligence 122, 1 (2000), 71–109. doi:10.1016/S0004-3702(00)00047-3DOI
  10. [10]Dennis Groos, Nils Jansen, Sebastian Junges, and Guillermo A Pérez. 2022. COOL-MC: a comprehensive tool for reinforcement learning and model checking. In Dependable Software Engineering: Theories, Tools, and Applications: 8th International Symposium, SETTA 2022, Beijing, China, October 27-29, 2022, Proceedings. Springer, 41–49.
  11. [11]Joseph Y. Halpern. 2016. Actual causality. MIT Press.
  12. [12]Joseph Y. Halpern and Judea Pearl. 2005. Causes and explanations: A structural-model approach. Part I. Causes. The British Journal for the Philosophy of Science 56, 4 (2005), 843–887.
  13. [13]Rodrigo Toro Icarte, Taryn Q Klassen, Richard Valenzano, and Sheila A McIlraith. 2022. Reward machines: Exploiting reward function structure in reinforcement learning. Journal of Artificial Intelligence Research 73 (2022), 173–208.DOI
  14. [14]Milad Kazemi, Jessica Lally, Ekaterina Tishchenko, Hana Chockler, and Nicola Paoletti. 2025. Counterfactual influence in Markov decision processes. In Proceedings of the Fourth Conference on Causal Learning and Reasoning (Proceedings of Machine Learning Research, Vol. 275), Biwei Huang and Mathias Drton (Eds.). PMLR, 792–817. https://proceedings.mlr.press/v275/kazemi25a.htmlarxiv.org/abs/2402.08514
  15. [15]Taylor W Killian, Maryzeh Ghamsemi, and Shalmali Joshi. 2022. Counterfactually guided policy transfer in clinical settings. In Conference on Health, Inference, and Learning. PMLR, 5–31.
  16. [16]M. Kwiatkowska, G. Norman, and D. Parker. 2011. PRISM 4.0: Verification of probabilistic real-time systems. In Proc. 23rd International Conference on Computer Aided Verification (CAV’11) (LNCS, Vol. 6806), G. Gopalakrishnan and S. Qadeer (Eds.). Springer, 585–591.
  17. [17]Jessica Lally, Milad Kazemi, and Nicola Paoletti. 2026. Robust counterfactual inference in Markov decision processes. In Proceedings of the 25th International Conference on Autonomous Agents and Multiagent Systems (Paphos, Cyprus) (AAMAS ’26). International Foundation for Autonomous Agents and Multiagent Systems, Richland, SC, 1527–1535. doi:10.65109/TYXQU4572arxiv.org/abs/2502.13731
  18. [18]Chaochao Lu, Biwei Huang, Ke Wang, José Miguel Hernández-Lobato, Kun Zhang, and Bernhard Schölkopf. 2020. Sample-efficient reinforcement learning via counterfactual-based data augmentation. arXiv preprint arXiv:2012.09092 (2020).arxiv.org/abs/2012.09092
  19. [19]Chris J Maddison, Daniel Tarlow, and Tom Minka. 2014. A* sampling. Advances in Neural Information Processing Systems 27 (2014).
  20. [20]Frederik Baymler Mathiesen, Morteza Lahijanian, and Luca Laurenti. 2024. IntervalMDP.jl: Accelerated value iteration for interval Markov decision processes. IFAC-PapersOnLine 58, 11 (2024), 1–6. 8th IFAC Conference on Analysis and Design of Hybrid Systems (ADHS 2024). doi:10.1016/j.ifacol.2024.07.416
  21. [21]Tobias Meggendorfer, Maximilian Weininger, and Patrick Wietenhöft. 2024. What are the odds? Improving the foundations of statistical model checking. arXiv preprint arXiv:2404.05424 (2024).arxiv.org/abs/2404.05424
  22. [22]Kimia Noorbakhsh and Manuel Gomez Rodriguez. 2022. Counterfactual temporal point processes. Advances in Neural Information Processing Systems 35 (2022), 24810–24823.arxiv.org/abs/2111.07603
  23. [23]Michael Oberst and David Sontag. 2019. Counterfactual off-policy evaluation with Gumbel-max structural causal models. In Proceedings of the 36th International Conference on Machine Learning (Proceedings of Machine Learning Research, Vol. 97), Ramalika Chaudhuri and Ruslan Salakhutdinov (Eds.). PMLR, 4881–4890. https://proceedings.mlr.press/v97/oberst19a.htmlarxiv.org/abs/1905.05824
  24. [24]Judea Pearl. 2009. Causality (2nd ed.). Cambridge University Press. doi:10.1017/CBO9780511803161
  25. [25]Edoardo Pona, Milad Kazemi, Yali Du, David Watson, and Nicola Paoletti. 2025. Abstract counterfactuals for language model agents. In Advances in Neural Information Processing Systems, D. Belgrave, C. Zhang, H. Lin, R. Pascanu, P. Koniusz, M. Ghassemi, and N. Chen (Eds.), Vol. 38, Main Conference. Curran Associates, Inc., 87484–87509. doi:10.52202/085713-2925DOI
  26. [26]Yannick Schnitzer, Alessandro Abate, and David Parker. 2025. Certifiably robust policies for uncertain parametric environments. In Tools and Algorithms for the Construction and Analysis of Systems, Arie Gurfinkel and Marijn Heule (Eds.). Springer Nature Switzerland, Cham, 63–83.
  27. [27]Marnix Suilen, Thiago D Simão, David Parker, and Nils Jansen. 2022. Robust anytime learning of Markov decision processes. Advances in Neural Information Processing Systems 35 (2022), 28790–28802.arxiv.org/abs/2205.15827
  28. [28]Yuewen Sun, Erli Wang, Biwei Huang, Chaochao Lu, Lu Feng, Changyin Sun, and Kun Zhang. 2024. ACAMDA: improving data efficiency in reinforcement learning through guided counterfactual data augmentation. In Proceedings of the AAAI Conference on Artificial Intelligence, Vol. 38. 15193–15201.
  29. [29]Stratis Tsirtsis, Abir De, and Manuel Gomez Rodriguez. 2021. Counterfactual explanations in sequential decision making under uncertainty. Advances in Neural Information Processing Systems 34 (2021), 30127–30139.arxiv.org/abs/2107.02776
  30. [30]Stratis Tsirtsis and Manuel Gomez Rodriguez. 2023. Finding counterfactually optimal action sequences in continuous state spaces. In Advances in Neural Information Processing Systems, A. Oh, T. Naumann, A. Globerson, K. Saenko, M. Hardt, and S. Levine (Eds.), Vol. 36. Curran Associates, Inc., 3220–3247.arxiv.org/abs/2306.03929
  31. [31]Marco Zaffalon, Alessandro Antonucci, Rafael Cabañas, David Huber, and Dario Azzimonti. 2024. Efficient computation of counterfactual bounds. International Journal of Approximate Reasoning 171 (2024), 109111. Synergies between Machine Learning and Reasoning. doi:10.1016/j.ijar.2023.109111DOI
  32. [32]Junzhe Zhang, Jin Tian, and Elias Bareinboim. 2022. Partial counterfactual identification from observational and experimental data. In Proceedings of the 39th International Conference on Machine Learning (Proceedings of Machine Learning Research, Vol. 162), Kamalika Chaudhuri, Stefanie Jegelka, Le Song, Csaba Szepesvari, Gang Niu, and Sivan Sabato (Eds.). PMLR, 26548–26558.arxiv.org/abs/2110.05690
  33. [33]Qingfu Zhu, Weinan Zhang, Ting Liu, and William Yang Wang. 2020. Counterfactual off-policy training for neural dialogue generation. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), 3438–3448.DOI

Paper details

vlnc:W_esq6jzhh
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 5

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents