Skip to content

Instantly share code, notes, and snippets.

@ChadFulton
Last active April 29, 2024 17:48
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save ChadFulton/a9172cd6f41947333f47bd4842832619 to your computer and use it in GitHub Desktop.
Save ChadFulton/a9172cd6f41947333f47bd4842832619 to your computer and use it in GitHub Desktop.
Large dynamic factor models, forecasting, and nowcasting in Statsmodels
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gustavogpf
Copy link

Great application and very useful notebook. In the 0.12 version of statsmodels will it also be possible to work with other frequencies (weekly/monthly: DynamicFactorWM? ) in the same way as shown for monthly/quarterly?

@ChadFulton
Copy link
Author

Thanks! For v0.12, it will only be monthly/quarterly. In the future, we will hopefully add support for additional mixed frequency combinations.

@yashwanth11
Copy link

Very useful notebook. Weekly/Monthly frequencies will be super helpful. Thanks!

@ChadFulton
Copy link
Author

Thanks, I'm glad it's helpful. Yes, I hope that we can add additional frequencies soon.

@samvanmeer
Copy link

Hi, I can not seem to open the url https://s3.amazonaws.com/files.fred.stlouisfed.org/fred-md. When running this notebook, I get: HTTP Error 403: Forbidden. Am I doing something wrong? Thanks in advance!

@SebKrantz
Copy link

Change base_url = 'https://files.stlouisfed.org/files/htdocs/fred-md'

@JNMedina75
Copy link

Hello, I'm trying to run the notebook, but I ran into an issue with the 'fredmd_definitions.csv' and 'fredqd_definitions.csv' files. I tried to access the URL in the notebook, but I was met with an error message. I then went to FRED website and downloaded the csv files, but they seem to have different column names, which is creating issues with the grouping.

Would you be able to share the csv appendix files used for the notebook.

Thank You!

@bigcodata
Copy link

hi, does NowCasting model predict a quarter-on-quarter growth rate of GDP? If it is a quarter-on-quarter growth rate, can it be predicted, or can it be calculated?

@jeaniek
Copy link

jeaniek commented Apr 4, 2024

Hi,
Thank you very much for sharing your work. I wonder if the DynamicFactorMQ can also work with the mixed frequency data between yearly and quarterly? And more importantly, if this package can also work with panel data (i.e. multiple countries with data observed across years). Many thanks again!

@lladamartin
Copy link

Hi,
Thank you very much for your work. I wonder how DynamicFactorMQ deals with missing data when you have non-synchronized release indexes. I couldn't find documentation about this issue. Could you please tell me a little more about this?

@ChadFulton
Copy link
Author

Hi @jeaniek, yes, you could use DynamicFactorMQ with quarterly / annual data, and with multiple countries and multiple years. NOte that the package does not do anything special in those cases; it would just be a typical dynamic factor model.

@ChadFulton
Copy link
Author

Hi @lladamartin, I'm not sure I understand exactly what you're asking. Generally, the model allows for arbitrary patterns of missing observations. For example, if you data through 2024Q1 for one dataset, while another dataset has only been released through 2023Q4, then you would have a NaN value for the second dataset for 2024Q1. The model would run just fine in this case.

@lladamartin
Copy link

Thank you for your response. I apologize for the lack of clarity in my question. I have monthly information on a set of indicators. These indicators have 1, 2, and up to 3 months of lag. I want to obtain the latent factor of this information set. How does the model estimate the value of the factor in April if many indicators have missing data for that month and previous months? How does the model handle those missing values?

@ChadFulton
Copy link
Author

Because it is a state space model, where the unobserved state has a defined transition equation, it can produce an estimate for the factor in April even if you had no data for the month (i.e. it just estimates April using its estimate for March combined with the definition of how the state transitions between periods). As you start to observe parts of the data for April, it updates its estimate using whatever data is available. A more detailed description of how this works can be found in, e.g., Maximum likelihood estimation of factor models on datasets with arbitrary pattern of missing data

@lladamartin
Copy link

I'll see the paper! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment