@@ -56,6 +56,57 @@ Current features include:
56
56
* Diagnostics for the residuals of fitted models
57
57
* Visualization recipes
58
58
59
+ ## Quick Examples
60
+
61
+ ### Fitting and forecasting
62
+ Quick example of different models fit and forecast for the air passengers time-series
63
+
64
+ ``` julia
65
+ using CSV
66
+ using DataFrames
67
+ using Plots
68
+ using StateSpaceModels
69
+
70
+ airp = CSV. File (StateSpaceModels. AIR_PASSENGERS) |> DataFrame
71
+ log_air_passengers = log .(airp. passengers)
72
+ steps_ahead = 30
73
+
74
+ # SARIMA
75
+ model_sarima = SARIMA (log_air_passengers; order = (0 , 1 , 1 ), seasonal_order = (0 , 1 , 1 , 12 ))
76
+ fit! (model_sarima)
77
+ forec_sarima = forecast (model_sarima, steps_ahead)
78
+
79
+ # Unobserved Components
80
+ model_uc = UnobservedComponents (log_air_passengers; trend = " local linear trend" , seasonal = " stochastic 12" )
81
+ fit! (model_uc)
82
+ forec_uc = forecast (model_uc, steps_ahead)
83
+
84
+ # Exponential Smoothing
85
+ model_ets = ExponentialSmoothing (log_air_passengers; trend = true , seasonal = 12 )
86
+ fit! (model_ets)
87
+ forec_ets = forecast (model_ets, steps_ahead)
88
+
89
+ # Naive model
90
+ model_naive = SeasonalNaive (log_air_passengers, 12 )
91
+ fit! (model_naive)
92
+ forec_naive = forecast (model_naive, steps_ahead)
93
+
94
+ plt_sarima = plot (model_sarima, forec_sarima; title = " SARIMA" , label = " " );
95
+ plt_uc = plot (model_uc, forec_uc; title = " Unobserved components" , label = " " );
96
+ plt_ets = plot (model_ets, forec_ets; title = " Exponential smoothing" , label = " " );
97
+ plt_naive = plot (model_ets, forec_naive; title = " Seasonal Naive" , label = " " );
98
+
99
+ plot (plt_sarima, plt_uc, plt_ets, plt_naive; layout = (2 , 2 ), size = (500 , 500 ))
100
+ ```
101
+ ![ quick_example_airp] ( ./docs/assets/quick_example_airp.png )
102
+
103
+ ### Automatic forecasting
104
+ Quick examples on automatic forecasting. When performing automatic forecasting
105
+ users should provide the seasonal period if there is one.
106
+ ``` julia
107
+ model = auto_ets (log_air_passengers; seasonal = 12 )
108
+ ```
109
+
59
110
## Contributing
60
111
61
112
* PRs such as adding new models and fixing bugs are very welcome!
0 commit comments