Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "StateSpaceLearning"
uuid = "971c4b7c-2c4e-4bac-8525-e842df3cde7b"
authors = ["andreramosfc <[email protected]>"]
version = "2.0.1"
version = "2.0.2"

[deps]
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Expand Down
18 changes: 11 additions & 7 deletions src/models/structural_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1226,13 +1226,17 @@ function get_cycle_decomposition(
end

for t in 2:T
ϕ_indexes =
max(2, model.stochastic_start):min(t, (T - max(1, model.ϕ_threshold)))
cycle[t] =
dot(c1, [cos(λ[t]), sin(λ[t])]) + sum(
ϕ_cos[i] * cos(λ[t]) + ϕ_sin[i] * sin(λ[t]) for
i in eachindex(ϕ_indexes)
)
if max(2, model.stochastic_start) <= min(t, (T - max(1, model.ϕ_threshold)))
ϕ_indexes =
max(2, model.stochastic_start):min(t, (T - max(1, model.ϕ_threshold)))
cycle[t] =
dot(c1, [cos(λ[t]), sin(λ[t])]) + sum(
ϕ_cos[i] * cos(λ[t]) + ϕ_sin[i] * sin(λ[t]) for
i in eachindex(ϕ_indexes)
)
else
cycle[t] = dot(c1, [cos(λ[t]), sin(λ[t])])
end
end

else
Expand Down
17 changes: 17 additions & 0 deletions test/models/structural_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,23 @@ end
model, model.output.components, slope
)
@test length(trend) == 10

model = StateSpaceLearning.StructuralModel(
rand(100);
cycle="stochastic",
cycle_period=3,
outlier=false,
slope="stochastic",
ζ_threshold=0,
freq_seasonal=3,
ω_threshold=0,
ϕ_threshold=0,
stochastic_start=30,
)
StateSpaceLearning.fit!(model)
@test length(
StateSpaceLearning.get_cycle_decomposition(model, model.output.components, 3)
) == 100
end

@testset "Function: simulate_states" begin
Expand Down
Loading