Giter VIP home page Giter VIP logo

nowcasting-python's Introduction

Nowcasting-Python

The repository contains Python code that is translated from a Matlab code which produces a dynamic factor model. The Matlab code and the model belong to the Federal Reserve Bank of New York, developed by Eric Qian and Brandyn Bok. Please visit their repository for further details.

The Matlab code being translated implements the nowcasting framework described in "Macroeconomic Nowcasting and Forecasting with Big Data" by Brandyn Bok, Daniele Caratelli, Domenico Giannone, Argia M. Sbordone, and Andrea Tambalotti, Staff Reports 830, Federal Reserve Bank of New York (prepared for Volume 10 of the Annual Review of Economics).

File and folder description

  • data/ : example US data downloaded from FRED
  • Functions/ : functions for loading data, estimating model, and updating predictions
  • example_DFM.py : example script to estimate a dynamic factor model (DFM) for a panel of monthly and quarterly series
  • example_Nowcast.py : example script to produce a nowcast or forecast for a target variable, e.g., real GDP growth
  • ResDFM.pickle : example DFM estimation output
  • Spec_US_example.xls : example model specification for the US

NOTICE:

This repository is not associated Federal Reserve Bank of New York. I am not well versed in dynamic factor modeling but the reason I created this repository was to challenge myself and I thought it would be cool to convert a model from matlab to python. So feel free to use it for academic purposes but make sure you give proper credit to Eric Qian and Brandyn Bok.

The repository is in its early stages and requires further improvements such as optimizing functions and writing clearer syntax with proper formatting. I'm not sure when I will get to this as I moved away from time series and started focusing on deep learning. My apologies for any inconviences. Feel free to post any technical issues that you encountered and I'll try my best to respond promptly.

Thanks,

MK

nowcasting-python's People

Contributors

majestickhan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nowcasting-python's Issues

Next steps

Unit testing

  • Create unit test to ensure python model is working properly

Graphs and formatting

  • Plotting graphs: finished plotting graphs for example_dfm.py in plot
  • Plot loglik in Plotly
  • Branch plot has been merged to the master. Should be able to see the graphs that are show in the Matlab code.

Comments:

  • Next set of tasks is working on creating unit tests

About update_Nowcast.py

Thanks for sharing your code.
Recently I'm learning about nowcasting models, your code is just what I need.
But I got something wrong when running your update_Nowcast.py,so I tried to fix it.

When I change the vintage, I may got error on line 407 ~ line 422,so I rewrite like this

for jk in range(1, lag + 1):

    Plag.append(np.zeros(Plag[0].shape))

    for jt in range(Plag[0].shape[0], lag, -1):

        As = np.matmul(np.matmul(Vf[jt-jk-1], A.T), np.linalg.pinv(np.matmul(np.matmul(A, Vf[jt-jk-1]), A.T) + Q))

        Plag[jk][jt-1] = np.matmul(As, Plag[jk-1][jt-1]) 

Also you mention that weight seems suspicious.
I find a mistake on line 281,it should be
if t_miss[j] > t_miss[i]:

I'm not sure whether line 245 should like this
m = max(t_miss[i],t_fcst[0])

Finally, I run the code with vintage_old = '2016-11-30' and vintage_new = '2016-12-23'.
I can get these:

          2016-11-30 nowcast:              2.80471
  Impact from data revisions:      0.10666
   Impact from data releases:      -0.49701
                                 +_________
                Total impact:      -0.39035
          2016-12-23 nowcast:              2.41436

Release Dates

Hey,

I dont know if this is an issue with how I am formatting data or something else, but I am trying to run the code on dataframes which have different release dates.

As a result I have formatted the data in a weekly format with NAs in between.

When I run this code i then either get the error:

ValueError: expected square matrix

or

ValueError: Internal work array size computation failed: -5

Ideally I would also be able to run with actual weekly data as an input.

Have attached the relevant files and would love any thoughts you have?
Spec_US_example.xlsx

2016-06-29.xlsx

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.