Emulation tests for MetaWards

Model description (parameters etc. ) are here

Based on Code from James Salter.

Code for this notebook is here

Warning: call dbDisconnect() when finished working with a connection

Emulating cumulative deaths in hostpital (cumHD) in the community (cumCD) at the beginning of lockdown

The DiceKriging Emulator fit for log(deaths) looks good. Leave-one-out isn’t a great measure, but it’s a start.

Week 12 cumulative Hospital deaths Leave-one-out plots

Week 12 cumulative community deaths Leave-one-out plots

Normalise input space and re-fit to produce some sensitivity analyses

one-at-a-time sensitivity for cumulative hospital deaths

one-at-a-time sensitivity for cumulative community deaths

FAST99 sensitivity analysis of Saltelli et al (1999)


Call:
fast99(model = NULL, factors = colnames(X_norm), n = 3000, q = "qunif",     q.arg = list(min = 0, max = 1))

Model runs: 45000 

Estimations of the indices:
                first order total order
R0             2.585428e-02 0.035929466
TE             8.449869e-03 0.012916688
TP             5.232931e-03 0.009794117
TI1            2.755023e-03 0.005637028
TI2            4.424181e-04 0.002651128
nuA            2.146632e-03 0.004908428
ns             3.161063e-03 0.006554266
p_home_weekend 2.465234e-05 0.002252227
alphaTH        1.251016e-02 0.014628540
etaTH          3.012345e-02 0.032340747
alphaEP        4.749904e-02 0.049844993
alphaI1D       4.128630e-04 0.002730804
alphaHD        6.479151e-01 0.665511700
alphaI1H       4.060805e-02 0.042927247
eta            1.532206e-01 0.155485294


Call:
fast99(model = NULL, factors = colnames(X_norm), n = 3000, q = "qunif",     q.arg = list(min = 0, max = 1))

Model runs: 45000 

Estimations of the indices:
                first order  total order
R0             2.863806e-02 0.0362205113
TE             7.500666e-03 0.0101285630
TP             8.205312e-03 0.0097800745
TI1            1.751677e-03 0.0032319492
TI2            1.808647e-04 0.0009642045
nuA            1.960271e-03 0.0031444349
ns             2.630065e-03 0.0041243613
p_home_weekend 2.258216e-04 0.0010491636
alphaTH        1.813378e-05 0.0007295074
etaTH          1.559330e-04 0.0008386092
alphaEP        4.130470e-02 0.0423746633
alphaI1D       8.163022e-01 0.8302459638
alphaHD        7.783550e-06 0.0011500901
alphaI1H       7.638476e-04 0.0041380489
eta            7.532251e-02 0.0764951926

This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.

Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).

The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.

LS0tCnRpdGxlOiAiTWV0YXdhcmRzIFdhdmUwNCIKb3V0cHV0OiBodG1sX25vdGVib29rCi0tLQoKCgojIyBFbXVsYXRpb24gdGVzdHMgZm9yIE1ldGFXYXJkcwoKTW9kZWwgZGVzY3JpcHRpb24gKHBhcmFtZXRlcnMgZXRjLiApIGFyZSBbaGVyZV0oaHR0cHM6Ly91cTRjb3ZpZC5naXRodWIuaW8vdmlnbmV0dGVzL2RhdGEvTWV0YVdhcmRzL3ZpZ25ldHRlL01vZGVsRGVzY3JpcHRpb24pICAKCkJhc2VkIG9uIENvZGUgZnJvbSBKYW1lcyBTYWx0ZXIuCgpDb2RlIGZvciB0aGlzIG5vdGVib29rIGlzIFtoZXJlXShodHRwczovL2dpdGh1Yi5jb20vZG91Z21jbmVhbGwvY292aWQvYmxvYi9tYXN0ZXIvamFtZXMvd2F2ZV8wM190ZXN0LlJtZCkKCmBgYHtyIHNldHVwLCBpbmNsdWRlPUZBTFNFfQprbml0cjo6b3B0c19jaHVuayRzZXQoZWNobyA9IEZBTFNFLCBtZXNzYWdlID0gRkFMU0UsIGVycm9yID0gRkFMU0UpCmBgYAoKYGBge3IsIGVjaG8gPSBGQUxTRSwgd2FybmluZyA9IEZBTFNFLCBtZXNzYWdlID0gRkFMU0V9CmxpYnJhcnkoUlNRTGl0ZSkKbGlicmFyeShmaWVsZHMpCmxpYnJhcnkodmlyaWRpcykKbGlicmFye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