Skip to content

Commit a803510

Browse files
fix explanatory
1 parent b5bfa5f commit a803510

File tree

5 files changed

+6
-30
lines changed

5 files changed

+6
-30
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "StateSpaceModels"
22
uuid = "99342f36-827c-5390-97c9-d7f9ee765c78"
33
authors = ["raphaelsaavedra <[email protected]>, guilhermebodin <[email protected]>, mariohsouto"]
4-
version = "0.5.14"
4+
version = "0.5.15"
55

66
[deps]
77
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"

src/models/basicstructural_explanatory.jl

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ function default_filter(model::BasicStructuralExplanatory)
6969
Fl = typeof_model_elements(model)
7070
steadystate_tol = Fl(1e-5)
7171
a1 = zeros(Fl, num_states(model))
72-
P1 = zeros(Fl, num_states(model), num_states(model))
73-
P1[1:13, 1:13] = Fl(1e6) .* Matrix{Fl}(I, 13, 13)
74-
return UnivariateKalmanFilter(a1, P1, 13, steadystate_tol)
72+
P1 = Fl(1e6) .* Matrix{Fl}(I, num_states(model), num_states(model))
73+
return UnivariateKalmanFilter(a1, P1, num_states(model), steadystate_tol)
7574
end
7675

7776
function initial_hyperparameters!(model::BasicStructuralExplanatory)
@@ -127,14 +126,6 @@ function fill_model_system!(model::BasicStructuralExplanatory)
127126
return model
128127
end
129128

130-
function fill_model_filter!(filter::KalmanFilter, model::BasicStructuralExplanatory)
131-
for i in axes(model.exogenous, 2)
132-
filter.kalman_state.a[i + 13] = get_constrained_value(model, get_beta_name(model, i))
133-
end
134-
return filter
135-
end
136-
137-
138129
function fill_H_in_time(model::BasicStructuralExplanatory, H::Fl) where Fl
139130
return fill_system_matrice_with_value_in_time(model.system.H, H)
140131
end

src/models/locallevelexplanatory.jl

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ end
5757
function default_filter(model::LocalLevelExplanatory)
5858
Fl = typeof_model_elements(model)
5959
a1 = zeros(Fl, num_states(model))
60-
# P1 is identity on sigma \eta and 0 otherwise.
61-
P1 = zeros(Fl, num_states(model), num_states(model))
62-
P1[1] = Fl(1e6)
60+
P1 = Fl(1e6) .* Matrix{Fl}(I, num_states(model), num_states(model))
6361
steadystate_tol = Fl(1e-5)
6462
return UnivariateKalmanFilter(a1, P1, num_states(model), steadystate_tol)
6563
end
@@ -110,13 +108,6 @@ function fill_model_system!(model::LocalLevelExplanatory)
110108
return model
111109
end
112110

113-
function fill_model_filter!(filter::KalmanFilter, model::LocalLevelExplanatory)
114-
for i in axes(model.exogenous, 2)
115-
filter.kalman_state.a[i + 1] = get_constrained_value(model, get_beta_name(model, i))
116-
end
117-
return filter
118-
end
119-
120111
function fill_H_in_time(model::LocalLevelExplanatory, H::Fl) where Fl
121112
return fill_system_matrice_with_value_in_time(model.system.H, H)
122113
end

test/models/basicstructural_explanatory.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@
1010
# For a fixed forecasting explanatory the variance must not decrease
1111
forec = forecast(model, ones(10, 2))
1212
@test monotone_forecast_variance(forec)
13-
kf = kalman_filter(model);
14-
ks = kalman_smoother(model);
15-
a = get_predictive_state(kf)
16-
@test a[1, 14] a[end, 14] atol=1e-3
17-
@test a[1, 15] a[end, 15] atol=1e-3
13+
kf = kalman_filter(model)
14+
ks = kalman_smoother(model)
1815
@test_throws AssertionError simulate_scenarios(model, 10, 1000, ones(5, 2))
1916
scenarios = simulate_scenarios(model, 10, 1000, ones(10, 2))
2017
test_scenarios_adequacy_with_forecast(forec, scenarios)

test/models/locallevelexplanatory.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,4 @@
4343
@test monotone_forecast_variance(forec)
4444
kf = kalman_filter(model)
4545
ks = kalman_smoother(model)
46-
a = get_predictive_state(kf)
47-
@test a[1, 2] a[end, 2] atol=1e-3
48-
@test a[1, 3] a[end, 3] atol=1e-3
4946
end

0 commit comments

Comments
 (0)