Skip to content

Commit d7b7b3b

Browse files
seabbsSamuelBrand1github-actions[bot]CompatHelper Julia
authored
Issue 408: ARMA and ARIMA models (#438)
* draft MA method * draft MA methd * use IDD for epsilon in all models * add MA benchmark * Add docs and tests for IDD * make episilon_t a arg of the latent model constructors * improve MA correctness * fully import EpiAwareUtils * add a test for IDD * add tests for MA.jl * add doc tests and unit tests + start on helper fn * more updatres to AR appraoc * chase down partial arg changes * clean up AR * clean up and add arma and arima helpers * Contributions towards Arma/Arima models (#531) * Patch: Switch to fork of benchmarkCI (#520) * patch to fork of benchmarkCI * put fork version of BenchmarkCI in [sources] * swap order * add EpiAware [source] * fix path * rm benchmarkCI from project * Patch fix: add `Manifest.toml` to benchmarking (#524) * trigger * Update benchmark.yaml * Update benchmark.yaml * commit benchmark Manifest * try alternate approach * Update benchmark.yaml * Update EpiMethod.jl * Update benchmark.yaml * change baseline to origin/main * remove trigger * rm other trigger * Issue 465: Add an infection generating model for ODE problems (#510) * CompatHelper: bump compat for Turing to 0.35 for package EpiAware, (drop existing compat) (#516) * CompatHelper: bump compat for Turing to 0.35 for package EpiAware, (drop existing compat) * Update Project.toml * fix Project.toml --------- Co-authored-by: CompatHelper Julia <[email protected]> Co-authored-by: Sam Abbott <[email protected]> Co-authored-by: Samuel Brand <[email protected]> Co-authored-by: Samuel Brand <[email protected]> * CompatHelper: bump compat for DynamicPPL to 0.30 for package EpiAware, (drop existing compat) (#528) Co-authored-by: CompatHelper Julia <[email protected]> * rename IDD -> IID * rename test file * Issue 529: Create null Latent model (#530) * Null Latent model * Null Latent model * fix doctest * fix generate_epiaware unit tests New usage of RW * fix turing method test underlying std of step size changed name * fix broadcast test Underlying std param changed name * fix HN unit test Default std prior had changed * fix AR unit tests --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: CompatHelper Julia <[email protected]> Co-authored-by: Sam Abbott <[email protected]> * revert define_ namming * clean out repeated utils from merge * fix MA tests * fix RW tests - feel made about RandomWalk vs AR naming * fix remaining unit tests that aren't doctests * update latent recovery test * try and fix doctests automatically * update all doctests to output nothing - this is awful * add doctests for arima and arma * fix doctest * clean up deps * update replication studies * add interface tests for combination functions and add benchmarks * add some basic theoretical properties tests * name change IDD -> IID benchmarks * moving all the constructors because this PR is too contained * catch missing using * update iid benchmark: * update extraction * remove old param namme from case study * get the dot * get the dot * fix initial guess point for MAP opt * Update index.jl * add a compile time branch for HN * add a compile time branch for HN * update test * add a new constructor to get old default behaviour * update docs * update docs - using the structs for priors is very brittle * reorder prior plots --------- Co-authored-by: Samuel Brand <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: CompatHelper Julia <[email protected]> Co-authored-by: Samuel Brand <[email protected]>
1 parent 8dc444f commit d7b7b3b

File tree

42 files changed

+977
-318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+977
-318
lines changed

EpiAware/docs/src/showcase/replications/chatzilena-2019/index.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### A Pluto.jl notebook ###
2-
# v0.20.0
2+
# v0.20.3
33

44
using Markdown
55
using InteractiveUtils
@@ -428,8 +428,8 @@ We define the AR(1) process by matching means of `HalfNormal` prior distribution
428428
# ╔═╡ 71a26408-1c26-46cf-bc72-c6ba528dfadd
429429
ar = AR(
430430
damp_priors = [HalfNormal(mean(sampled_AR_damps))],
431-
std_prior = HalfNormal(mean(sampled_AR_stds)),
432-
init_priors = [Normal(0, 0.001)]
431+
init_priors = [Normal(0, 0.001)],
432+
ϵ_t = HierarchicalNormal(std_prior = HalfNormal(mean(sampled_AR_stds)))
433433
)
434434

435435
# ╔═╡ e1ffdaf6-ca2e-405d-8355-0d8848d005b0
@@ -578,9 +578,10 @@ rand(stochastic_mdl)
578578
initial_guess = [[mean(chn[]),
579579
mean(chn[]),
580580
mean(chn[:S₀]),
581-
mean(ar.std_prior),
582581
mean(ar.init_prior)[1],
583-
mean(ar.damp_prior)[1]]
582+
mean(ar.damp_prior)[1],
583+
mean(ar.ϵ_t.std_prior)
584+
]
584585
zeros(13)]
585586

586587
# ╔═╡ 685221ea-f268-4ddc-937f-e7620d065c28
@@ -611,7 +612,7 @@ chn2 = sample(
611612
describe(chn2)
612613

613614
# ╔═╡ 37a016d8-8384-41c9-abdd-23e88b1f988d
614-
pairplot(chn2[[, , :S₀, Symbol(mdl_prefix * ".σ_AR"),
615+
pairplot(chn2[[, , :S₀, Symbol(mdl_prefix * ".std"),
615616
Symbol(mdl_prefix * ".ar_init[1]"), Symbol(mdl_prefix * ".damp_AR[1]")]])
616617

617618
# ╔═╡ 7df5d669-d3a2-4a66-83c3-f8618e39bec6

EpiAware/docs/src/showcase/replications/mishra-2020/index.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### A Pluto.jl notebook ###
2-
# v0.20.0
2+
# v0.20.3
33

44
using Markdown
55
using InteractiveUtils
@@ -114,10 +114,10 @@ In _Mishra et al_ the standard deviation of the _stationary distribution_ of $Z_
114114

115115
# ╔═╡ c88bbbd6-0101-4c04-97c9-c5887ef23999
116116
ar = AR(
117-
damp_priors = reverse([truncated(Normal(0.8, 0.05), 0, 1),
118-
truncated(Normal(0.1, 0.05), 0, 1)]),
119-
std_prior = HalfNormal(0.5),
120-
init_priors = [Normal(-1.0, 0.1), Normal(-1.0, 0.5)]
117+
damp_priors = [truncated(Normal(0.1, 0.05), 0, 1),
118+
truncated(Normal(0.8, 0.05), 0, 1)],
119+
init_priors = [Normal(-1.0, 0.1), Normal(-1.0, 0.5)],
120+
ϵ_t = HierarchicalNormal(std_prior = HalfNormal(0.5))
121121
)
122122

123123
# ╔═╡ 31ee2757-0409-45df-b193-60c552797a3d
@@ -561,11 +561,11 @@ let
561561
sub_chn = inference_results.samples[inference_results.samples.name_map.parameters[[1:5;
562562
end]]]
563563
fig = pairplot(sub_chn)
564-
lines!(fig[1, 1], ar.std_prior, label = "Prior")
565-
lines!(fig[2, 2], ar.init_prior.v[1], label = "Prior")
566-
lines!(fig[3, 3], ar.init_prior.v[2], label = "Prior")
567-
lines!(fig[4, 4], ar.damp_prior.v[1], label = "Prior")
568-
lines!(fig[5, 5], ar.damp_prior.v[2], label = "Prior")
564+
lines!(fig[1, 1], ar.init_prior.v[1], label = "Prior")
565+
lines!(fig[2, 2], ar.init_prior.v[2], label = "Prior")
566+
lines!(fig[3, 3], ar.damp_prior.v[1], label = "Prior")
567+
lines!(fig[4, 4], ar.damp_prior.v[2], label = "Prior")
568+
lines!(fig[5, 5], ar.ϵ_t.std_prior, label = "Prior")
569569
lines!(fig[6, 6], epi.initialisation_prior, label = "Prior")
570570

571571
fig

EpiAware/src/EpiAwareUtils/HalfNormal.jl

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,62 @@ Create a half-normal prior distribution with the specified mean.
1111
1212
# Examples:
1313
14-
```jldoctest HalfNormal
14+
```jldoctest HalfNormal; output = false
1515
using EpiAware, Distributions
1616
1717
hn = HalfNormal(1.0)
18+
nothing
19+
1820
# output
19-
EpiAware.EpiAwareUtils.HalfNormal{Float64}(μ=1.0)
21+
2022
```
2123
22-
# filter out all the values that are less than 0
23-
```jldoctest HalfNormal; filter = r\"\b\d+(\.\d+)?\b\" => \"*\"
24+
```jldoctest HalfNormal; output = false
2425
rand(hn)
26+
nothing
27+
2528
# output
26-
0.4508533245229199
29+
2730
```
2831
29-
```jldoctest HalfNormal
32+
```jldoctest HalfNormal; output = false
3033
cdf(hn, 2)
34+
nothing
35+
3136
# output
32-
0.8894596502772643
37+
3338
```
3439
35-
```jldoctest HalfNormal
40+
```jldoctest HalfNormal; output = false
3641
quantile(hn, 0.5)
42+
nothing
43+
3744
# output
38-
0.8453475393951495
45+
3946
```
4047
41-
```jldoctest HalfNormal
48+
```jldoctest HalfNormal; output = false
4249
logpdf(hn, 2)
50+
nothing
51+
4352
# output
44-
-3.1111166111445083
53+
4554
```
4655
47-
```jldoctest HalfNormal
56+
```jldoctest HalfNormal; output = false
4857
mean(hn)
58+
nothing
59+
4960
# output
50-
1.0
61+
5162
```
5263
53-
```jldoctest HalfNormal
64+
```jldoctest HalfNormal; output = false
5465
var(hn)
66+
nothing
67+
5568
# output
56-
0.5707963267948966
69+
5770
```
5871
"
5972
struct HalfNormal{T <: Real} <: ContinuousUnivariateDistribution

EpiAware/src/EpiAwareUtils/SafeNegativeBinomial.jl

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ parameterisation is useful for specifying the distribution in a way that is easi
2727
2828
# Examples:
2929
30-
```jldoctest SafeNegativeBinomial
30+
```jldoctest SafeNegativeBinomial; output = false
3131
using EpiAware, Distributions
3232
3333
bigμ = exp(48.0) #Large value of μ
@@ -37,32 +37,42 @@ bigμ = exp(48.0) #Large value of μ
3737
p = bigμ / σ²
3838
r = bigμ * p / (1 - p)
3939
d = SafeNegativeBinomial(r, p)
40+
nothing
41+
4042
# output
41-
EpiAware.EpiAwareUtils.SafeNegativeBinomial{Float64}(r=20.0, p=2.85032816548187e-20)
43+
4244
```
4345
44-
```jldoctest SafeNegativeBinomial
46+
```jldoctest SafeNegativeBinomial; output = false
4547
cdf(d, 100)
48+
nothing
49+
4650
# output
47-
0.0
51+
4852
```
4953
50-
```jldoctest SafeNegativeBinomial
54+
```jldoctest SafeNegativeBinomial; output = false
5155
logpdf(d, 100)
56+
nothing
57+
5258
# output
53-
-850.1397180331871
59+
5460
```
5561
56-
```jldoctest SafeNegativeBinomial
62+
```jldoctest SafeNegativeBinomial; output = false
5763
mean(d)
64+
nothing
65+
5866
# output
59-
7.016735912097631e20
67+
6068
```
6169
62-
```jldoctest SafeNegativeBinomial
70+
```jldoctest SafeNegativeBinomial; output = false
6371
var(d)
72+
nothing
73+
6474
# output
65-
2.4617291430060293e40
75+
6676
```
6777
"
6878
struct SafeNegativeBinomial{T <: Real} <: SafeDiscreteUnivariateDistribution

EpiAware/src/EpiAwareUtils/SafePoisson.jl

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,47 @@ when the mean is too large.
1212
1313
# Examples:
1414
15-
```jldoctest SafePoisson
15+
```jldoctest SafePoisson; output = false
1616
using EpiAware, Distributions
1717
1818
bigλ = exp(48.0) #Large value of λ
1919
d = SafePoisson(bigλ)
20+
nothing
21+
2022
# output
21-
EpiAware.EpiAwareUtils.SafePoisson{Float64}(λ=7.016735912097631e20)
23+
2224
```
2325
24-
```jldoctest SafePoisson
26+
```jldoctest SafePoisson; output = false
2527
cdf(d, 2)
28+
nothing
29+
2630
# output
27-
0.0
31+
2832
```
2933
30-
```jldoctest SafePoisson
34+
```jldoctest SafePoisson; output = false
3135
logpdf(d, 100)
36+
nothing
37+
3238
# output
33-
-7.016735912097631e20
39+
3440
```
3541
36-
```jldoctest SafePoisson
42+
```jldoctest SafePoisson; output = false
3743
mean(d)
44+
nothing
45+
3846
# output
39-
7.016735912097631e20
47+
4048
```
4149
42-
```jldoctest SafePoisson
50+
```jldoctest SafePoisson; output = false
4351
var(d)
52+
nothing
53+
4454
# output
45-
7.016735912097631e20
55+
4656
```
4757
"
4858
struct SafePoisson{T <: Real} <: SafeDiscreteUnivariateDistribution

EpiAware/src/EpiAwareUtils/censored_pmf.jl

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,17 @@ Raises:
2323
2424
# Examples
2525
26-
```jldoctest filter
26+
```jldoctest; output = false
2727
using Distributions
2828
using EpiAware.EpiAwareUtils
2929
3030
dist = Exponential(1.0)
3131
32-
censored_pmf(dist, Val(:single_censored); D = 10) |>
33-
p -> round.(p, digits=3)
32+
censored_pmf(dist, Val(:single_censored); D = 10)
33+
nothing
3434
3535
# output
36-
10-element Vector{Float64}:
37-
0.393
38-
0.383
39-
0.141
40-
0.052
41-
0.019
42-
0.007
43-
0.003
44-
0.001
45-
0.0
46-
0.0
36+
4737
```
4838
"
4939
function censored_pmf(dist::Distribution,
@@ -122,28 +112,17 @@ to nearest multiple of `Δd`.
122112
123113
# Examples
124114
125-
```jldoctest filter
115+
```jldoctest filter; output = false
126116
using Distributions
127117
using EpiAware.EpiAwareUtils
128118
129119
dist = Exponential(1.0)
130120
131-
censored_cdf(dist; D = 10) |>
132-
p -> round.(p, digits=3)
121+
censored_cdf(dist; D = 10)
122+
nothing
133123
134124
# output
135-
11-element Vector{Float64}:
136-
0.0
137-
0.368
138-
0.767
139-
0.914
140-
0.969
141-
0.988
142-
0.996
143-
0.998
144-
0.999
145-
1.0
146-
1.0
125+
147126
```
148127
"
149128
function censored_cdf(dist::Distribution; Δd = 1.0, D = nothing, upper = 0.999)
@@ -184,27 +163,17 @@ to nearest multiple of `Δd`.
184163
185164
# Examples
186165
187-
```jldoctest filter
166+
```jldoctest filter; output = false
188167
using Distributions
189168
using EpiAware.EpiAwareUtils
190169
191170
dist = Exponential(1.0)
192171
193-
censored_pmf(dist; D = 10) |>
194-
p -> round.(p, digits=3)
172+
censored_pmf(dist; D = 10)
173+
nothing
195174
196175
# output
197-
10-element Vector{Float64}:
198-
0.368
199-
0.4
200-
0.147
201-
0.054
202-
0.02
203-
0.007
204-
0.003
205-
0.001
206-
0.0
207-
0.0
176+
208177
```
209178
"
210179
function censored_pmf(dist::Distribution; Δd = 1.0, D = nothing, upper = 0.99)

0 commit comments

Comments
 (0)