Giter Site home page Giter Site logo

anachikashua / statespacemodels.jl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lampspuc/statespacemodels.jl

0.0 0.0 0.0 7.46 MB

StateSpaceModels.jl is a Julia package for time-series analysis using state-space models.

Home Page: https://lampspuc.github.io/StateSpaceModels.jl/latest/

License: MIT License

Julia 100.00%

statespacemodels.jl's Introduction

StateSpaceModels.jl

Build Status Coverage Documentation
Build Status Codecov branch

StateSpaceModels.jl is a package for modeling, forecasting, and simulating time series in a state-space framework. Implementations were made based on the book "Time Series Analysis by State Space Methods" (2012) by James Durbin and Siem Jan Koopman. The notation of the variables in the code also follows the book.

Quickstart

import Pkg

Pkg.add("StateSpaceModels")

using StateSpaceModels

y = randn(100)

model = LocalLevel(y)

fit!(model)

print_results(model)

forecast(model, 10)

kf = kalman_filter(model)

v = get_innovations(kf)

ks = kalman_smoother(model)

alpha = get_smoothed_state(ks)

Features

Current features include:

  • Kalman filter and smoother
  • Maximum likelihood estimation
  • Forecasting and Monte Carlo simulation
  • User-defined models (user specifies the state-space system)
  • Several predefined models, including:
    • Exponential Smoothing (ETS, all the linear ones)
    • Unobserved components (local level, basic structural, ...)
    • SARIMA
    • Linear regression
    • Naive models
  • Completion of missing values
  • Diagnostics for the residuals of fitted models
  • Visualization recipes

Quick Examples

Fitting and forecasting

Quick example of different models fit and forecast for the air passengers time-series

using CSV
using DataFrames
using Plots
using StateSpaceModels

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

# SARIMA
model_sarima = SARIMA(log_air_passengers; order = (0, 1, 1), seasonal_order = (0, 1, 1, 12))
fit!(model_sarima)
forec_sarima = forecast(model_sarima, steps_ahead)

# Unobserved Components
model_uc = UnobservedComponents(log_air_passengers; trend = "local linear trend", seasonal = "stochastic 12")
fit!(model_uc)
forec_uc = forecast(model_uc, steps_ahead)

# Exponential Smoothing
model_ets = ExponentialSmoothing(log_air_passengers; trend = true, seasonal = 12)
fit!(model_ets)
forec_ets = forecast(model_ets, steps_ahead)

# Naive model
model_naive = SeasonalNaive(log_air_passengers, 12)
fit!(model_naive)
forec_naive = forecast(model_naive, steps_ahead)

plt_sarima = plot(model_sarima, forec_sarima; title = "SARIMA", label = "");
plt_uc = plot(model_uc, forec_uc; title = "Unobserved components", label = "");
plt_ets = plot(model_ets, forec_ets; title = "Exponential smoothing", label = "");
plt_naive = plot(model_ets, forec_naive; title = "Seasonal Naive", label = "");

plot(plt_sarima, plt_uc, plt_ets, plt_naive; layout = (2, 2), size = (500, 500))

quick_example_airp

Automatic forecasting

Quick examples on automatic forecasting. When performing automatic forecasting users should provide the seasonal period if there is one.

model = auto_ets(log_air_passengers; seasonal = 12)
model = auto_arima(log_air_passengers; seasonal = 12)

Contributing

  • PRs such as adding new models and fixing bugs are very welcome!
  • For nontrivial changes, you'll probably want to first discuss the changes via issue.

Citing StateSpaceModels.jl

If you use StateSpaceModels.jl in your work, we kindly ask you to cite the following paper:

@article{SaavedraBodinSouto2019,
  title={StateSpaceModels.jl: a Julia Package for Time-Series Analysis in a State-Space Framework},
  author={Raphael Saavedra and Guilherme Bodin and Mario Souto},
  journal={arXiv preprint arXiv:1908.01757},
  year={2019}
}

statespacemodels.jl's People

Contributors

guilhermebodin avatar raphaelsaavedra avatar iagochavarry avatar mariohsouto avatar azev77 avatar bgroenks96 avatar juliatagbot avatar juliohm avatar marinadietze avatar dietzemarina avatar pkofod avatar psrcloud 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.