Git Product home page Git Product logo

seasonal-arimax-renewable-impact-analysis2's Introduction

sarimax-models

Estimate S-ARIMA-X models with Stochastic Gradient Descent or Kalman Filter

What is S-ARIMA-X?

It stands for Seasonal AutoRegressive Integrated Moving Average with eXogenous variables...

The formulation is:

           sarimax_eqn

Estimation

We need to estimate those greek letters, i.e., the S-AR, S-MA, X parameters of the model, which is said to be of order (p, d, q)(P, D, Q)[m].

First way is to use Stochastic Gradient Descent (SGD). Logic is this: we fit a large AR(p) model first, get the residuals of it and use it as the unobserved noise in the formulation. Then we form the design matrix and employ SGD to find all the parameters.

Second way is via MLE: we put the S-ARIMA-X into a (Hamiltonian) state space formulation, run a Kalman filter for likelihood and a numerical optimizer solves for parameters (e.g, L-BFGS). statsmodels does something like this, too; but they also offer Harvey's representation (that's the default and used in below example).

Example result

Here is a sample monthly data from M3 Competiton dataset. Black vertical line is train-test split point. All models have the order (2, 1, 1)(1, 0, 2)[12]:

m3_data_comparison

Usage

For SGD:

from sgd_sarimax import SARIMAX_SGD
model = SARIMAX_SGD(endog, exog, order=(2, 1, 3), seas_order=(1, 1, 0, 4))
model.fit(max_iter=5_000, eta0=0.1)

preds_in_sample = model.predict_in_sample()
forecasts = model.forecast(steps=10)

For KF:

from kalman_sarimax import SARIMAX_KF
model = SARIMAX_KF(endog, exog, order=(2, 1, 3), seas_order=(1, 1, 0, 4))
model.fit()

preds_in_sample = model.predict_in_sample()
forecasts = model.forecast(steps=10)

seasonal-arimax-renewable-impact-analysis2's People

Contributors

mustafaaydn avatar slzhang-git avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.