QuantEcon.jl icon indicating copy to clipboard operation
QuantEcon.jl copied to clipboard

Feature request: standard econ filters/smoothers

Open jstac opened this issue 7 years ago • 15 comments

I don't think there are any packages in Julia that implement nice versions of the standard filters used in econ, like the HP filter. See, e.g., time series filters here:

http://statsmodels.sourceforge.net/stable/tsa.html#time-series-filters

This is another important filter, for seasonal adjustment:

https://www.census.gov/srd/www/x13as/x13down_unix.html

In Python and R there are wrappers:

https://github.com/christophsax/seasonal http://statsmodels.sourceforge.net/devel/_modules/statsmodels/tsa/x13.html

but not Julia, as far as I know.

jstac avatar Jul 19 '16 21:07 jstac

Sébastian Villemot @sebastien-villemot wrote command to implement the hpfilter would likely be easy enough to just use his as base for the package. He likes free software so I imagine he would be happy enough for you to use it. http://www.econforge.org/posts/2014/juil./28/cef2014-julia/

robertdkirkby avatar Jul 20 '16 05:07 robertdkirkby

Sure, feel free to reuse that code under a BSD or GPL license.

svillemot avatar Jul 20 '16 16:07 svillemot

@sebastien-villemot Many thanks.

Anyone interested in this project please let me know.

jstac avatar Jul 20 '16 17:07 jstac

I will work on some of the time series filters from statsmodels.

vgregory757 avatar Oct 13 '16 15:10 vgregory757

Sounds great.

Make sure to check the license on stats models before looking at their code.

sglyon avatar Oct 13 '16 15:10 sglyon

Statsmodels seems to be licensed under Modified BSD (3-clause)

cc7768 avatar Oct 13 '16 16:10 cc7768

How about the seasonality filter with X-13ARIMA, did that suggestion go places, or does it exist in another package?

emonigma avatar Jul 23 '18 16:07 emonigma

I am interested in the project. As this issue is still marked open, is anyone working on it?

andi3141 avatar Sep 21 '20 16:09 andi3141

@Shunsuke-Hori , you did some work with filters didn't you?

jstac avatar Sep 21 '20 19:09 jstac

@jstac @andi3141 Yes

  • HP filter: https://github.com/QuantEcon/QuantEcon.jl/blob/master/src/filter.jl#L12
  • Hamilton filter: https://github.com/QuantEcon/QuantEcon.jl/blob/master/src/filter.jl#L44
  • Kalman smoother: https://github.com/QuantEcon/QuantEcon.jl/blob/master/src/kalman.jl#L186
    • Not mine, but there is a PR for Kalman filter in #235
  • two more PRs (to be merged, I think): BK filter (#223) and regime-switching (#250)

Shunsuke-Hori avatar Sep 21 '20 19:09 Shunsuke-Hori

@andi3141 , would you be willing to look at the existing filters in the library, linked to above, and then review those open PRs?

That might be a good way to get started.

@sglyon How does this sound to you? (Some of those PRs have already had input and could be ready to merge without further review.)

jstac avatar Sep 21 '20 22:09 jstac

@jstac sure, no problem. Happy to help

andi3141 avatar Sep 22 '20 12:09 andi3141

Thanks @jstac that sounds good to me.

@andi3141 please take a look at the pull requests and leave a comment when you've finished reviewing. Then we can work towards getting them merged.

sglyon avatar Sep 22 '20 14:09 sglyon

So I had a look at the HP, Hamilton, and BK filter, which all seem fine. I am currently looking at the Kalman filter. In the pull request 235, an example file kalman_tracking_2d_example.jl is added to the example folder. What is the purpose of these example files? Are those files supposed to run without any packages added prior? There is only one other example file in the library so far, so it is hard for me to judge.

andi3141 avatar Oct 07 '20 14:10 andi3141

@andi3141

Are those files supposed to run without any packages added prior?

I guess so, though I'm not the person who added them. Example codes are typically used to illustrate practical usage of a package. I don't think it's strictly necessary in this repository, but it won't hurt to have it (as long as it works).

If you could check the example file as well and leave a comment on #235, that would be great.

Shunsuke-Hori avatar Dec 11 '20 09:12 Shunsuke-Hori