StateSpaceModels.Forecast output are not callable/iterable

ultratrader
Wed, 27 Sep 2023 13:24:31 +0000
General Usage

Hi all,
I tried to extract the output of the forecast function in StateSpaceModels.jl after fitting using auto_arima() and convert it to an array for further computation. I am using Julia 1.9.2 and StateSpaceModels.jl v.0.6.7. This is the simplified version of my problems using a sample dataset as well as their related error

using CSV
using DataFrames
using Plots
using StateSpaceModels

airp = CSV.File(StateSpaceModels.AIR_PASSENGERS) |> DataFrame
log_air_passengers = log.(airp.passengers)

model = auto_arima(log_air_passengers; seasonal = 12)

k = forecast(model, 10)
h = collect(values(k)) #no method matching length StateSpaceModels.Forecast{Float64}
h = values(k[1]) #no method matching getindex StateSpaceModels.Forecast{Float64}
k[1] ##no method matching getindex
h = [[i] for i in k] ##no method matching length
typeof(k) #StateSpaceModels.Forecast{Float64}
typeof(k) #StateSpaceModels.Forecast{Float64}
a = Array(k) # no method matching Array()
b = collect(k) #no method matching length

Really appreciate your help.

3 posts - 2 participants