Coder Social home page Coder Social logo

yannickkae / multivariate-forecasting-var-vs.-lstm Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 4.19 MB

VAR vs. LSTM: Multivariate Forecasting of Factor Returns

License: Creative Commons Zero v1.0 Universal

Jupyter Notebook 100.00%
factor-investing finance forecasting lstm multivariate-timeseries vector-autoregressive

multivariate-forecasting-var-vs.-lstm's Introduction

Multivariate Time Series Forecasting: VAR vs. LSTM

I explored two different approaches to forecasting multivariate time series data, using the Value, Momentum, Carry, and Defensive factors as examples. I compared the performance of a Multivariate LSTM model (multiple output neurons) and a Vector Autoregression (VAR) model.

Data

The monthly return data used in this analysis are from the paper How Do Factor Premia Vary Over Time? A Century of Evidence by Ilmanen et al. (2019). It explores the following four factor strategies across liquid asset classes:

  1. Value
  2. Momentum
  3. Carry
  4. Defensive

Cumulative Performance of Factors

Models

Vector Autoregression (VAR)

I first applied a VAR model for forecasting the factors' returns, following these steps:

  1. Test for stationarity using the Augmented Dickey-Fuller (ADF) test.
  2. Fit the VAR model with an optimal lag order, determined by minimizing the BIC.
  3. Analyze the model output.
  4. Forecast the factors' returns using the fitted model.
  5. Evaluate the forecast accuracy using the Mean Absolute Percentage Error (MAPE).

Multivariate LSTM

Next, I applied a Multivariate LSTM model for forecasting the factors' returns, following these steps:

  1. Scale the dataset using the MinMaxScaler.
  2. Split the dataset into training and testing sets.
  3. Reshape the input data into a 3D array format for the LSTM model.
  4. Create an LSTM model with Conv1D, Dropout, and Dense layers.
  5. Perform hyperparameter tuning with 10-fold cross-validation and RandomizedSearchCV.
  6. Train the model and forecast the factors' returns using it.
  7. Evaluate the forecast accuracy using the Mean Absolute Percentage Error (MAPE).

Results

MAPE Comparison

Conclusion

The forecast accuracy for both models was relatively poor. The Multivariate LSTM model performed better for Value and Defensive, while the VAR model performed better for Momentum and Carry. Ultimately, the differences in performance were marginal, leading me to go with Occam's Razor and select the simpler model, i.e., the VAR. The fact that a more complex model, like LSTM, did not significantly improve the results could suggest that the features, i.e. past returns, may not be a reliable predictor of future returns, a notion commonly accepted in the field.

Garbage in, garbage out. You can't math noise into signal.

multivariate-forecasting-var-vs.-lstm's People

Contributors

yannickkae avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  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.