1
1
export simulate, forecast_quantiles
2
2
3
3
"""
4
- simulate(series::Vector{T}, gas::Model{D, T}, N ::Int, S::Int, kwargs...) where {D, T}
4
+ simulate(series::Vector{T}, gas::Model{D, T}, H ::Int, S::Int, kwargs...) where {D, T}
5
5
6
- Generate scenarios for the future of a time series by updating the GAS recursion `N ` times and taking
6
+ Generate scenarios for the future of a time series by updating the GAS recursion `H ` times and taking
7
7
a sample of the distribution until it generates `S` scenarios.
8
8
9
9
By default this method uses the `stationary_initial_params` method to perform the
10
10
score driven recursion. If you estimated the model with a different set of `initial_params`
11
11
use them here to maintain the coherence of your estimation.
12
12
"""
13
- function simulate (series:: Vector{T} , gas:: Model{D, T} , N :: Int , S:: Int ;
13
+ function simulate (series:: Vector{T} , gas:: Model{D, T} , H :: Int , S:: Int ;
14
14
initial_params:: Matrix{T} = stationary_initial_params (gas)) where {D, T}
15
15
# Filter params estimated on the time series
16
16
params = score_driven_recursion (gas, series; initial_params = initial_params)
@@ -19,9 +19,9 @@ function simulate(series::Vector{T}, gas::Model{D, T}, N::Int, S::Int;
19
19
20
20
params_simulation = params[(end - biggest_lag): (end - 1 ), :]
21
21
# Create scenarios matrix
22
- scenarios = Matrix {T} (undef, N , S)
22
+ scenarios = Matrix {T} (undef, H , S)
23
23
for scenario in 1 : S
24
- sim, param = simulate_recursion (gas, N + biggest_lag + 1 ; initial_params = params_simulation)
24
+ sim, param = simulate_recursion (gas, H + biggest_lag + 1 ; initial_params = params_simulation)
25
25
scenarios[:, scenario] = sim[biggest_lag + 2 : end ]
26
26
end
27
27
30
30
31
31
32
32
"""
33
- forecast_quantiles(series::Vector{T}, gas::Model{D, T}, N ::Int; kwargs...) where {D, T}
33
+ forecast_quantiles(series::Vector{T}, gas::Model{D, T}, H ::Int; kwargs...) where {D, T}
34
34
35
- Forecast quantiles for future values of a time series by updating the GAS recursion `N ` times and
35
+ Forecast quantiles for future values of a time series by updating the GAS recursion `H ` times and
36
36
using Monte Carlo method as in Blasques, Francisco, Siem Jan Koopman,
37
37
Katarzyna Lasak and Andre Lucas (2016): "In-Sample Confidence Bounds and Out-of-Sample Forecast
38
38
Bands for Time-Varying Parameters in Observation Driven Models",
@@ -47,11 +47,11 @@ By default this method uses the `stationary_initial_params` method to perform th
47
47
score driven recursion. If you estimated the model with a different set of `initial_params`
48
48
use them here to maintain the coherence of your estimation.
49
49
"""
50
- function forecast_quantiles (series:: Vector{T} , gas:: Model{D, T} , N :: Int ;
50
+ function forecast_quantiles (series:: Vector{T} , gas:: Model{D, T} , H :: Int ;
51
51
initial_params:: Matrix{T} = stationary_initial_params (gas),
52
- quantiles:: Vector{T} = T .([0.025 , 0.5 , 0.975 ]), S:: Int = 1000 ) where {D, T}
52
+ quantiles:: Vector{T} = T .([0.025 , 0.5 , 0.975 ]), S:: Int = 10_000 ) where {D, T}
53
53
54
- scenarios = simulate (series, gas, N , S; initial_params = initial_params)
54
+ scenarios = simulate (series, gas, H , S; initial_params = initial_params)
55
55
56
56
return get_quantiles (quantiles, scenarios)
57
57
end
0 commit comments