Skip to content

Commit 1d3a1b2

Browse files
committed
paper draft
1 parent 499fc54 commit 1d3a1b2

File tree

1 file changed

+167
-0
lines changed

1 file changed

+167
-0
lines changed

paper.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
---
2+
title: 'The Causal Testing Framework'
3+
tags:
4+
- Python
5+
- causal testing
6+
- causal inference
7+
- causality
8+
- software testing
9+
- metamorphic testing
10+
authors:
11+
- name: Michael Foster
12+
orcid: 0000-0001-8233-9873
13+
affiliation: 1
14+
corresponding: true
15+
- name: Christopher Wild
16+
orcid: 0009-0009-1195-1497
17+
affiliation: 1
18+
- name: Farhad Allian
19+
affiliation: 1
20+
- name: Richard Somers
21+
orcid: 0009-0009-1195-1497
22+
affiliation: 1
23+
- name: Neil Walkinshaw
24+
orcid: 0000-0003-2134-6548
25+
affiliation: 1
26+
- name: Nicolas Lattimer
27+
affiliation: 1
28+
affiliations:
29+
- name: University of Sheffield, UK
30+
index: 1
31+
date: 2 December 2024
32+
bibliography: paper.bib
33+
---
34+
35+
# Summary
36+
Scientific models possess several properties that make them notoriously difficult to test, including a complex input space, long execution times, and non-determinism, rendering existing testing techniques impractical.
37+
In fields such as epidemiology, where researchers seek answers to challenging causal questions, a statistical methodology known as Causal Inference has addressed similar problems, enabling the inference of causal conclusions from noisy, biased, and sparse observational data instead of costly randomised trials.
38+
Causal Inference works by using domain knowledge to identify and mitigate for biases in the data, enabling them to answer causal questions that concern the effect of changing some feature on the observed outcome.
39+
The Causal Testing Framework is a software testing framework that uses Causal Inference techniques to establish causal effects between software variables from pre-existing runtime data rather than having to collect bespoke, highly curated datasets especially for testing.
40+
41+
# Statement of need
42+
Metamorphic Testing is a popular technique for testing computational models (and other traditionally "hard to test" software).
43+
Test goals are expressed as _metamorphic relations_ that specify how changing an input in a particular way should affect the software output.
44+
Nondeterministic software can be tested using statistical metamorphic testing, which uses statistical tests over multiple executions of the software to determine whether the specified metamorphic relations hold.
45+
However, this requires the software to be executed repeatedly for each set of parameters of interest, so is computationally expensive, and is constrained to testing properties over software inputs that can be directly and precisely controlled.
46+
Statistical metamorphic testing cannot be used to test properties that relate internal variables or outputs to each other, since these cannot be controlled a priori.
47+
48+
By employing domain knowledge in the form of a causal graph --- a lightweight model specifying the expected relationships between key software variables --- the Causal Testing Framework circumvents both of these problems by enabling models to be tested using pre-existing runtime data.
49+
The causal testing framework is written in python but is language agnostic in terms of the system under test.
50+
All that is required is a set of properties to be validated, a causal model, and a set of software runtime data.
51+
52+
# Causal Testing
53+
Causal Testing has four main steps, outlined in \ref{fig:schematic}.
54+
Firstly, the user supplies a causal model, which takes the form of a directed acyclic graph (DAG) in which an edge $X \to Y$ represents variable $X$ having a direct causal effect on variable $Y$.
55+
Secondly, the user supplies a set of causal properties to be tested.
56+
Such properties can be generated from the causal DAG: for each $X \to Y$ edge, a test to validate the presence of a causal effect is generated, and for each missing edge, a test to validate independence is generated.
57+
The user may also refine tests to validate the nature of a particular relationship.
58+
Next, the user supplies a set of runtime data in the form of a table with each column representing a variable and rows containing the value of each variable for a particular run of the software.
59+
Finally, the Causal Testing Framework automatically validates the supplied causal properties by using the supplied causal DAG and data to calculate a causal effect estimate, and validating this against the expected causal relationship.
60+
61+
![Causal Testing workflow.\label{fig:schematic}](images/schematic.png)
62+
63+
## Test Adequacy
64+
Because the properties being tested are completely separate from the data used to validate them, traditional coverage-based metrics are not appropriate here.
65+
The Causal Testing Framework instead evaluates the adequacy of a particular dataset by calculating a statistical metric based on the stability of the causal effect estimate, with numbers closer to zero representing more adequate data.
66+
67+
## Missing Variables
68+
Causal Testing works by using the supplied causal DAG to identify those variables which need to be statistically controlled for to remove their biassing effect on the causal estimate.
69+
This typically means we need to know their values.
70+
However, the Causal Testing Framework can still sometimes estimate unbiased causal effects using Instrumental Variables, an advanced Causal Inference technique.
71+
72+
## Feedback
73+
Many scientific models involve iterating several interacting processes over time.
74+
These processes often feed into each other, and can create feedback cycles.
75+
Traditional Causal Inference cannot handle this, however the Causal Testing Framework uses another advanced Causal Inference technique, g-methods, to enable the estimation of causal effects even when there are feedback cycles between variables.
76+
77+
# Citations
78+
79+
Citations to entries in paper.bib should be in
80+
[rMarkdown](http://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html)
81+
format.
82+
83+
If you want to cite a software repository URL (e.g. something on GitHub without a preferred
84+
citation) then you can do it with the example BibTeX entry below for @fidgit.
85+
86+
For a quick reference, the following citation commands can be used:
87+
- `@author:2001` -> "Author et al. (2001)"
88+
- `[@author:2001]` -> "(Author et al., 2001)"
89+
- `[@author1:2001; @author2:2001]` -> "(Author1 et al., 2001; Author2 et al., 2002)"
90+
91+
# Figures
92+
93+
Figures can be included like this:
94+
![Caption for example figure.\label{fig:example}](figure.png)
95+
and referenced from text using \autoref{fig:example}.
96+
97+
Figure sizes can be customized by adding an optional second parameter:
98+
![Caption for example figure.](figure.png){ width=20% }
99+
100+
# Acknowledgements
101+
102+
We acknowledge contributions from Brigitta Sipocz, Syrtis Major, and Semyeong
103+
Oh, and support from Kathryn Johnston during the genesis of this project.
104+
105+
# References
106+
107+
Example paper.bib file:
108+
109+
@article{Pearson:2017,
110+
url = {http://adsabs.harvard.edu/abs/2017arXiv170304627P},
111+
Archiveprefix = {arXiv},
112+
Author = {{Pearson}, S. and {Price-Whelan}, A.~M. and {Johnston}, K.~V.},
113+
Eprint = {1703.04627},
114+
Journal = {ArXiv e-prints},
115+
Keywords = {Astrophysics - Astrophysics of Galaxies},
116+
Month = mar,
117+
Title = {{Gaps in Globular Cluster Streams: Pal 5 and the Galactic Bar}},
118+
Year = 2017
119+
}
120+
121+
@book{Binney:2008,
122+
url = {http://adsabs.harvard.edu/abs/2008gady.book.....B},
123+
Author = {{Binney}, J. and {Tremaine}, S.},
124+
Booktitle = {Galactic Dynamics: Second Edition, by James Binney and Scott Tremaine.~ISBN 978-0-691-13026-2 (HB).~Published by Princeton University Press, Princeton, NJ USA, 2008.},
125+
Publisher = {Princeton University Press},
126+
Title = {{Galactic Dynamics: Second Edition}},
127+
Year = 2008
128+
}
129+
130+
@article{gaia,
131+
author = {{Gaia Collaboration}},
132+
title = "{The Gaia mission}",
133+
journal = {Astronomy and Astrophysics},
134+
archivePrefix = "arXiv",
135+
eprint = {1609.04153},
136+
primaryClass = "astro-ph.IM",
137+
keywords = {space vehicles: instruments, Galaxy: structure, astrometry, parallaxes, proper motions, telescopes},
138+
year = 2016,
139+
month = nov,
140+
volume = 595,
141+
doi = {10.1051/0004-6361/201629272},
142+
url = {http://adsabs.harvard.edu/abs/2016A%26A...595A...1G},
143+
}
144+
145+
@article{astropy,
146+
author = {{Astropy Collaboration}},
147+
title = "{Astropy: A community Python package for astronomy}",
148+
journal = {Astronomy and Astrophysics},
149+
archivePrefix = "arXiv",
150+
eprint = {1307.6212},
151+
primaryClass = "astro-ph.IM",
152+
keywords = {methods: data analysis, methods: miscellaneous, virtual observatory tools},
153+
year = 2013,
154+
month = oct,
155+
volume = 558,
156+
doi = {10.1051/0004-6361/201322068},
157+
url = {http://adsabs.harvard.edu/abs/2013A%26A...558A..33A}
158+
}
159+
160+
@misc{fidgit,
161+
author = {A. M. Smith and K. Thaney and M. Hahnel},
162+
title = {Fidgit: An ungodly union of GitHub and Figshare},
163+
year = {2020},
164+
publisher = {GitHub},
165+
journal = {GitHub repository},
166+
url = {https://github.com/arfon/fidgit}
167+
}

0 commit comments

Comments
 (0)