-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clean up and add arma and arima helpers
- Loading branch information
Showing
6 changed files
with
121 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
@doc raw""" | ||
Define an ARIMA model by wrapping `define_arma` and applying differencing via `DiffLatentModel`. | ||
# Arguments | ||
- `ar_init`: Prior distribution for AR initial conditions. | ||
A vector of distributions. | ||
- `d_init`: Prior distribution for differencing initial conditions. | ||
A vector of distributions. | ||
- `θ`: Prior distribution for MA coefficients. | ||
A vector of distributions. | ||
- `damp`: Prior distribution for AR damping coefficients. | ||
A vector of distributions. | ||
- `ϵ_t`: Distribution of the error term. | ||
Default is `HierarchicalNormal()`. | ||
# Returns | ||
An ARIMA model consisting of AR and MA components with differencing applied. | ||
# Example | ||
```julia | ||
using EpiAware, Distributions | ||
ARIMA = arima( | ||
ar_init = [Normal(0.0, 1.0)], | ||
d_init = [Normal()], | ||
θ = [truncated(Normal(0.0, 0.02), -1, 1)], | ||
damp = [truncated(Normal(0.0, 0.02), 0, 1)] | ||
) | ||
arma_model = generate_latent(ARIMA, 10) | ||
arma_model() | ||
``` | ||
""" | ||
function arima(; | ||
ar_init = [Normal()], | ||
d_init = [Normal()], | ||
damp = [truncated(Normal(0.0, 0.05), 0, 1)], | ||
θ = [truncated(Normal(0.0, 0.05), -1, 1)], | ||
ϵ_t = HierarchicalNormal() | ||
) | ||
arma = define_arma(; init = ar_init, damp = damp, θ = θ, ϵ_t = ϵ_t) | ||
arima_model = DiffLatentModel(; model = arma, init_priors = d_init) | ||
return arima_model | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
@doc raw""" | ||
Define an ARMA model using AR and MA components. | ||
# Arguments | ||
- `init`: Prior distribution for AR initial conditions. | ||
A vector of distributions. | ||
- `θ`: Prior distribution for MA coefficients. | ||
A vector of distributions. | ||
- `damp`: Prior distribution for AR damping coefficients. | ||
A vector of distributions. | ||
- `ϵ_t`: Distribution of the error term. | ||
Default is `HierarchicalNormal()`. | ||
# Returns | ||
An AR model with an MA model as its error term, effectively creating an ARMA model. | ||
# Example | ||
```@example | ||
using EpiAware, Distributions | ||
ARMA = define_arma(; | ||
θ = [truncated(Normal(0.0, 0.02), -1, 1)], | ||
damp = [truncated(Normal(0.0, 0.02), 0, 1)] | ||
) | ||
arma = generate_latent(ARMA, 10) | ||
arma() | ||
``` | ||
""" | ||
function define_arma(; | ||
init = [Normal()], | ||
damp = [truncated(Normal(0.0, 0.05), 0, 1)], | ||
θ = [truncated(Normal(0.0, 0.05), -1, 1)], | ||
ϵ_t = HierarchicalNormal()) | ||
ma = MA(; θ_priors = θ, ϵ_t = ϵ_t) | ||
ar = AR(; damp_priors = damp, init_priors = init, ϵ_t = ma) | ||
return ar | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters