Skip to content

Cannot predict for more steps than number of observations #324

@SupplyChef

Description

@SupplyChef

When trying to sample future scenarios from a BasicStructuralExplanatory model, I get the error shown below. I believe this is because the sampling code reuses the arrays (ie, Z) that were sized with the number of observations used to fit the model. This fails when the number of steps to sample for is greater than the number of observations.

BoundsError: attempt to access 9-element Vector{Vector{Float64}} at index [10]
│ Stacktrace:
│ [1] getindex(A::Vector{Vector{Float64}}, i1::Int64)
│ @ Base .\essentials.jl:13
│ [2] simulate(model::StateSpaceModels.BasicStructuralExplanatory, initial_state::Vector{Float64}, n::Int64, new_exogenous::Matrix{Float64}; return_simulated_states::Bool)
│ @ StateSpaceModels C:\Users\renau.julia\packages\StateSpaceModels\DmxMT\src\models\basicstructural_explanatory.jl:209
│ [3] simulate
│ @ C:\Users\renau.julia\packages\StateSpaceModels\DmxMT\src\models\basicstructural_explanatory.jl:182 [inlined]
│ [4] simulate_scenarios(model::StateSpaceModels.BasicStructuralExplanatory, steps_ahead::Int64, n_scenarios::Int64, new_exogenous::Array{Float64, 3}; filter::StateSpaceModels.UnivariateKalmanFilter{Float64})
│ @ StateSpaceModels C:\Users\renau.julia\packages\StateSpaceModels\DmxMT\src\models\basicstructural_explanatory.jl:177
│ [5] simulate_scenarios(model::StateSpaceModels.BasicStructuralExplanatory, steps_ahead::Int64, n_scenarios::Int64, new_exogenous::Array{Float64, 3})
│ @ StateSpaceModels C:\Users\renau.julia\packages\StateSpaceModels\DmxMT\src\models\basicstructural_explanatory.jl:161
│ [6] sample_structural_explanatory(dates::Vector{Dates.Date}, values::Vector{Float64}, seasonality::Int64, event_dates::Vector{Dates.Date}, events::Vector{String}, horizon::Int64; scenario_count::Int64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions