Trouble using for loop for SARIMA

Agnes_H
Sat, 10 Dec 2022 23:31:55 +0000
General Usage

Hi, I apologize in advance, most of my programming skills are self-taught, if there are any weird errors.

My goal with this code was to basically create a for-loop that iterates over every column in my data frame separately with the data frame so that by the end I have a independent output for each column.

But so far I have been unable to generate any output with my function neither plots or anything else.
I used the StateSpaceModels.jl as my example, but the best output I got so far was SARIMA (generic function with 1 method)

I now humble ask if there is any way I can fix this?

begin
	function SARIMA(tsf::DataFrame, p::Int, d::Int, q::Int)
 	forecasts = Array{Float64, 3}(tsf.cols(2:22), 3)
  	for i = tsf.cols(2:22)
		# SARIMA
		steps_ahead = 30
    		model_sarima = SARIMA(tsf[i], order = (0,1,1), seasonal_order = (0, 1, 1, 4))
		fit!(model_sarima)
		forec_sarima = forecast(model_sarima, steps_ahead)

		# Exponential Smoothing
		model_ets = ExponentialSmoothing(tsf[i], trend = true, seasonal = 12)
		fit!(model_ets)
		forec_ets = forecast(model_ets, steps_ahead)

		# Naive model
		model_naive = SeasonalNaive(tsf[i], 12)
		fit!(model_naive)
		forec_naive = forecast(model_naive, steps_ahead)

		plt_sarima = plot(model_sarima, forec_sarima, layout =(22,1),title = "SARIMA", label = "")
		plt_ets = plot!(forec_ets, layout =(22,1), title = "Exponential smoothing", label = "")
		plt_naive = plot!(forec_naive, layout =(22,1), title = "Seasonal Naive", label = "")
		println(plt_naive)
		end
	end
end

2 posts - 2 participants