Skip to content

Commit

Permalink
Add documentation and export for eigenvalues
Browse files Browse the repository at this point in the history
  • Loading branch information
giovannic committed Jun 29, 2020
1 parent 61e9fc7 commit b2be310
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
8 changes: 6 additions & 2 deletions R/export.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,26 @@ names(countries) <- unique(squire::population$iso3c)

out_dir <- args[1]
for (iso3c in names(countries)) {
R0 <- 3;
pars <- parameters_explicit_SEEIR(
countries[[iso3c]],
hosp_bed_capacity = 1, #dummy value
ICU_bed_capacity = 1 #dummy value
ICU_bed_capacity = 1, #dummy value
R0 = R0
)

country_data <- list(
population = pars$population,
contactMatrix = pars$mix_mat_set,
beta = pars$beta
beta = pars$beta,
eigen = R0 / pars$beta
)

write_json(
country_data,
file.path(out_dir, paste0(iso3c, '.json')),
matrix='columnmajor',
auto_unbox=TRUE,
digits=NA
)
}
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,25 @@ Results will be an object representing a table of data. It will have the followi
Names: The names of the columns of the table. The first name will be t, identifying the time step column. The following names will identify the state and the age group being counted in that column. The age group will be identified in square brackets. E.g. the "S[1]" column represents the count for susceptables in the first age group.

Y: A 2D array representing the rows of the table. The first dimension will depend on the time steps and resolution of the model. The second dimension will be the same size as "Names".

#### beta and Rt

The model is parameterised with a country specific `beta` value.

To translate Rt values into beta values, you can divide them by the country
specific eigen value, e.g:

```
import nigeriaData from './data/NGA.json';
const r0 = 3;
const rt = [r0, r0/2];
const beta = rt.map(r => { return r / nigeriaData.eigen });
```

You can translate back to Rt by multiplying by the eigen value:

```
import nigeriaData from './data/NGA.json';
const beta = [nigeriaData.beta, nigeriaData.beta/2];
const rt = beta.map(r => { return r * nigeriaData.eigen });
```
14 changes: 14 additions & 0 deletions test/test_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ describe('runModel', function() {
})
});

it('can translate between beta from R0', function() {
const beta = [stlucia.beta, stlucia.beta/2];
const r0 = 3;
const rt = [r0, r0/2];

rt.map(r => { return r / stlucia.eigen }).forEach((value, i) => {
expect(beta[i]).to.be.closeTo(value, 1e-6);
});

beta.map(b => { return b * stlucia.eigen }).forEach((value, i) => {
expect(rt[i]).to.be.closeTo(value, 1e-6);
});
});

it('parameterises beds correctly', function() {
const expected = pars;

Expand Down

0 comments on commit b2be310

Please sign in to comment.