You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* add prefixing to ConcatLatentModels
* start working on concatlatentmodels
* fix concat constructor
* add tests for ConcatLatentModels
* add draft ascertainment method
* work on tests
* use latent_model not latentmodel
* use latent_model not latentmodel
* fix Ascertainment constructors
* add tests for prefix_submodel
* start to add helper strucs
* add tests and constructors for Prefix wrappers around prefix_submodel
* reduce custom code by using Prefix constructors
* switch stackobservation models to using new prefixwrapper
* fix ascertaiment to use latent models
* fix testing issues related to prefix_submodel
* fix final tests
Copy file name to clipboardExpand all lines: EpiAware/src/EpiLatentModels/manipulators/CombineLatentModels.jl
+28-9Lines changed: 28 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
@docraw"
2
2
The `CombineLatentModels` struct.
3
3
4
-
This struct is used to combine multiple latent models into a single latent model.
4
+
This struct is used to combine multiple latent models into a single latent model. If a prefix is supplied wraps each model with `PrefixLatentModel`.
5
5
6
6
# Constructors
7
-
8
-
- `CombineLatentModels(models::M) where {M <: AbstractVector{<:AbstractTuringLatentModel}}`: Constructs a `CombineLatentModels` instance with specified models, ensuring that there are at least two models.
9
-
- `CombineLatentModels(; models::M) where {M <: AbstractVector{<:AbstractTuringLatentModel}}`: Constructs a `CombineLatentModels` instance with specified models, ensuring that there are at least two models.
7
+
- `CombineLatentModels(models::M, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, P <: AbstractVector{<:String}}`: Constructs a `CombineLatentModels` instance with specified models and prefixes, ensuring that there are at least two models and the number of models and prefixes are equal.
8
+
- `CombineLatentModels(models::M) where {M <: AbstractVector{<:AbstractTuringLatentModel}}`: Constructs a `CombineLatentModels` instance with specified models, automatically generating prefixes for each model. The
9
+
automatic prefixes are of the form `Combine.1`, `Combine.2`, etc.
Copy file name to clipboardExpand all lines: EpiAware/src/EpiLatentModels/manipulators/ConcatLatentModels.jl
+34-16Lines changed: 34 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,10 @@ This struct is used to concatenate multiple latent models into a single latent m
5
5
6
6
# Constructors
7
7
8
-
- `ConcatLatentModels(models::M, no_models::Int, dimension_adaptor::Function) where {M <: AbstractVector{<:AbstractTuringLatentModel}}`: Constructs a `ConcatLatentModels` instance with specified models, number of models, and dimension adaptor.
9
-
- `ConcatLatentModels(models::M, dimension_adaptor::Function) where {M <: AbstractVector{<:AbstractTuringLatentModel}}`: Constructs a `ConcatLatentModels` instance with specified models and dimension adaptor, ensuring that there are at least two models. The default dimension adaptor is `equal_dimensions`.
10
-
- `ConcatLatentModels(; models::M, dimension_adaptor::Function) where {M <: AbstractVector{<:AbstractTuringLatentModel}}`: Constructs a `ConcatLatentModels` instance with specified models and dimension adaptor, ensuring that there are at least two models. The default dimension adaptor is `equal_dimensions`.
8
+
- `ConcatLatentModels(models::M, no_models::I, dimension_adaptor::F, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, I <: Int, F <: Function, P <: AbstractVector{String}}`: Constructs a `ConcatLatentModels` instance with specified models, number of models, dimension adaptor, and prefixes.
9
+
- `ConcatLatentModels(models::M, dimension_adaptor::F; prefixes::P = \"Concat.\" * string.(1:length(models))) where {M <: AbstractVector{<:AbstractTuringLatentModel}, F <: Function}`: Constructs a `ConcatLatentModels` instance with specified models and dimension adaptor. The number of models is automatically determined as are the prefixes (of the form `Concat.1`, `Concat.2`, etc.) by default.
10
+
- `ConcatLatentModels(models::M; dimension_adaptor::Function, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, P <: AbstractVector{String}}`: Constructs a `ConcatLatentModels` instance with specified models, dimension adaptor, prefixes, and automatically determines the number of models.The default dimension adaptor is `equal_dimensions`. The default prefixes are of the form `Concat.1`, `Concat.2`, etc.
11
+
- `ConcatLatentModels(; models::M, dimension_adaptor::Function, prefixes::P) where {M <: AbstractVector{<:AbstractTuringLatentModel}, P <: AbstractVector{String}}`: Constructs a `ConcatLatentModels` instance with specified models, dimension adaptor, prefixes, and automatically determines the number of models. The default dimension adaptor is `equal_dimensions`. The default prefixes are of the form `Concat.1`, `Concat.2`, etc.
11
12
12
13
# Examples
13
14
@@ -19,46 +20,62 @@ latent_model()
19
20
```
20
21
"
21
22
struct ConcatLatentModels{
22
-
M <:AbstractVector{<:AbstractTuringLatentModel}, N <:Int, F <:Function} <:
23
+
M <:AbstractVector{<:AbstractTuringLatentModel}, N <:Int, F <:Function, P <:
24
+
AbstractVector{<:String}} <:
23
25
AbstractTuringLatentModel
24
26
"A vector of latent models"
25
27
models::M
26
28
"The number of models in the collection"
27
29
no_models::N
28
30
"The dimension function for the latent variables. By default this divides the number of latent variables by the number of models and returns a vector of dimensions rounding up the first element and rounding down the rest."
29
31
dimension_adaptor::F
32
+
"A vector of prefixes for the latent models"
33
+
prefixes::P
30
34
31
35
functionConcatLatentModels(models::M,
32
36
no_models::I,
33
-
dimension_adaptor::F) where {
37
+
dimension_adaptor::F, prefixes::P) where {
34
38
M <:AbstractVector{<:AbstractTuringLatentModel}, I <:Int,
35
-
F <:Function}
39
+
F <:Function, P <:AbstractVector{<:String}}
36
40
@assertlength(models)>1"At least two models are required"
37
41
@assertlength(models)==no_models "no_models must be equal to the number of models"
38
42
# check all dimension functions take a single n and return an integer
Copy file name to clipboardExpand all lines: EpiAware/src/EpiObsModels/StackObservationModels.jl
+6-3Lines changed: 6 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
@docraw"
2
2
3
3
A stack of observation models that are looped over to generate observations for
4
-
each model in the stack. Note that the model names are used to prefix the parameters in each model (so if I have a model named `cases` and a parameter `y_t`, the parameter in the model will be `cases.y_t`).
4
+
each model in the stack. Note that the model names are used to prefix the parameters in each model (so if I have a model named `cases` and a parameter `y_t`, the parameter in the model will be `cases.y_t`). Inside the constructor `PrefixObservationModel` is wrapped around each observation model.
5
5
6
6
## Constructors
7
7
@@ -48,7 +48,10 @@ deaths_y_t
48
48
N <:AbstractString
49
49
}
50
50
@assertlength(models)==length(model_names) "The number of models and model names must be equal."
0 commit comments