README.md 2.22 KB
Newer Older
Chris Jewell's avatar
Chris Jewell committed
1
# GEM: a domain-specific language for epidemic modelling
Chris Jewell's avatar
Chris Jewell committed
2
3
4
5
6
7
8

GEM is a toolkit for epidemic analysis.  It is a probabilistic
programming language that allows users to define an epidemic
process in a clear, repeatable language, and embed that process
into a higher-order probabilistic model.  It provides for both simulation
and inference processes.

Chris Jewell's avatar
Chris Jewell committed
9
10
11
12
GEM documentation: [https://gem.readthedocs.io](https://gem.readthedocs.io)

## Quickstart

Chris Jewell's avatar
Chris Jewell committed
13
14
15
To install GEM:

```bash
Chris Jewell's avatar
Chris Jewell committed
16
$ pip install git+http://fhm-chicas-code.lancs.ac.uk/GEM/gem.git
Chris Jewell's avatar
Chris Jewell committed
17
18
19
20
21
22
23
24
25
```

Example usage:

```python
from gem import GEM
from gem.plotting import plot_timeseries, traceplot

prog = """
26
27
beta ~ Gamma(2.0, 10.0)
gamma ~ Gamma(1.0, 10.0)
Chris Jewell's avatar
Chris Jewell committed
28
29
30
31
32
33
34

Epidemic MyEpidemic() {

    S = State(init=999)
    I = State(init=1)
    R = State(init=0)
    
35
    [S -> I] = beta * I / 1000.0
Chris Jewell's avatar
Chris Jewell committed
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
    [I -> R] = gamma
}
epi ~ MyEpidemic()
"""

model = GEM(prog)

# Simulate
sim = model.sample(1, condition_vars={'beta': [0.4], 'gamma': [0.14]})
plot_timeseries(model.random_variables['epi'], sim['epi'])

# Inference
posterior, accept = model.fit(observed={'epi': sim['epi']}, n_samples=5000,
                              init=[0.001, 0.001], burnin=2000)
traceplot(posterior)
```

## Status

GEM is currently very much in alpha testing, with the interface likely to change without warning.  So far, the software is able to perform inference on epidemic models with known transition times.  It can also perform inference on a range of non-epidemic probabilistic models.

Watch this space in the coming year for developments in GEM, specifically around partially-observed epidemic processes and hidden-Markov models.

## Get involved

If you like the idea of GEM, get involved!  Clone the Git repo, and/or contact the project leader, Chris Jewell <c.jewell@lancaster.ac.uk>.

## Acknowledgements

I'd very much like to thank the [University of Lancaster](http://www.lancaster.ac.uk) for providing me a base from which to develop GEM, [CHICAS](http://chicas.lancaster-university.uk/) my group at Lancaster, and most of all [The Wellcome Trust](http://www.wellcome.ac.uk) for providing funding [funding](https://wellcome.ac.uk/funding/people-and-projects/grants-awarded/gem-translational-software-outbreak-analysis) to take GEM to the next level.