TSAnalysis: time series analysis and state-space modelling

Hi all,

I am a third-year PhD student in Statistics at the London School of Economics and Political Science.

I just released the first version of TSAnalysis (https://github.com/fipelle/TSAnalysis.jl). This package includes basic tools for time series analysis and state-space modelling. I plan to create an environment for forecasting centred on TSAnalysis and based on my doctoral research.

TSAnalysis is written entirely in Julia (for now, it is a rather small package). In addition to simple Arrays, it uses data structures from LinearAlgebra for symmetric and diagonal matrices. This is particularly beneficial for the stability and speed of Kalman routines, estimation algorithms (e.g., the EM algorithm in Shumway and Stoffer, 1982), and to handle high-dimensional forecasting problems.

This is my first Julia package - any feedback is very welcome!


  • R. H. Shumway and D. S. Stoffer. An approach to time series smoothing and forecasting using the EM algorithm. Journal of time series analysis, 3(4):253–264, 1982.

Was it developed in response to inadequate packages in the R ecosystem? What are the reason for creating a Julia pkg apart from that it is fun and Julia doesn’t have one?


I developed this package as a lightweight base for some computationally expensive methods that I am using in my PhD thesis (I will release these forecasting methods in the coming months). It was not in direct response to packages (or lack thereof) in R or any other language.

There are several time series packages. However, focusing on state-space modelling, I found that:

  • Alternative filtering and smoothing routines are sometimes unstable, inefficient or not compatible with incomplete data (i.e., data with missing observations).
  • Other approaches are not efficient for computing h-step ahead forecasts in out-of-sample evaluations.

Data structures from LinearAlgebra, the use of @view and structuring the code in simple blocks help, and I needed a single package for state-space modelling. Obviously, it was also for the fun :slight_smile:


Hi Thanks for sharing.

You mention state-space frequently, but from reading the documentation I don’t think you do delay coordinate embeddings but some other (observation/transition equations) state space reconstructions.

Are your methods related in any way with the ones described in Nonlinear Timeseries Analysis by Kantz ?

p.s.: an example showing a prediction made with your package (like this one: https://juliadynamics.github.io/TimeseriesPrediction.jl/dev/localmodels/#single-timeseries-example ) would make the readme better I feel.

That’s great to see, as the forecast package is pretty much the only thing these days I go back to R for. Are you planning on doing something similar, maybe a TSForecast package that has auto ARIMA, ETS etc?

1 Like


Thank you for your feedback!

@Datseris You are correct, I am not. For now, I am supporting linear state-space models à la Harvey (1990), Durbin and Koopman (2012), and co-authors. There is a small example with kforecast in the readme, but I recon that it is not great. I will expand on that :slight_smile:

@nilshg Yes. In the coming releases I will try to extend support to the following methods:

  • ARIMA models
  • Standard (aka textbook) univariate decompositions (e.g., seasonal adjustments)
  • ACFs ,CCFs and other basic functions for time series analysis. I know there is plenty of support already, but I feel that they should be included in a TS package.

After, it would be nice to cover TVP versions of the models above. I am not planning to release estimation algorithms anytime soon - I think I will rely on Optim for now.


  • Harvey, A. C. (1990). Forecasting, structural time series models and the Kalman filter . Cambridge university press.
  • Durbin, J., & Koopman, S. J. (2012). Time series analysis by state space methods . Oxford university press.

FYI the forecast package in R is really nice. Probably one of the best time-series packages around (and written by a fellow Aussie - Rob Hyndman down in Melbourne).


@fipelle for ARIMA there is https://github.com/Datseris/ARFIMA.jl . It works very well and it is very fast. I haven’t written tests for it because I never cared to released it as a proper julia package, but if you want to add is as a dependency you can just contribute basic tests via a PR and we can release it.

Thank you! Although it is an interesting package, I am already halfway through the completion of the some of the tasks described above, including implementation of the ARIMA.

As soon as I will have all the building blocks for TSAnalysis, I will post a precise list of features I would like to add. This should help us organise and collaborate better :slight_smile:

@nilshg: a first support for the ARIMA model is on dev.

I have documented it only via docstrings and I am currently debugging it. I will probably make some other changes, but it should be already functional enough to try it.

In order to estimate an ARIMA(d,p,q) you need to

  1. Define an ARIMASettings.

    • For example arima_settings = ARIMASettings(Y, 0, 1, 1).
    • Y is a row vector.
  2. Run arima(arima_settings).

The forecast function computes the forecast for the model. I have not implemented a version of forecast to compute the prediction in the original scale of Y yet. I will register a new version once this is done (and the above fully debugged).

Ideally, simple (univariate and linear) state-space models will have a similar sintax.