mrghg / py12box_invert

MIT License
3 stars 0 forks source link

Growth rates #5

Closed lukewestern closed 3 years ago

lukewestern commented 3 years ago

Added function to calculate growth rates. Approach taken is to take the first difference (x_i+1- x_i) and use KZ filter to calculate the rolling average (currently 12 month window, 1 iteration). Uncertainty is Monte Carlo using this KZ approach, sampling from the posterior cov matrix. Annual growth rates are just the mean of the monthly growth rates (with uncertainty from the ensemble).

New KZ filter module added but it's overkill if only using 1 iteration, and could easily be added as a small function if sticking with one iteration.

Note sure how this compares to IDL implementation using KZ filter.

lukewestern commented 3 years ago

I've now added a growth rates plot, which plots with plot_mf().

I've also fixed a bug which was causing the tests to fail in this branch. Will do some work on the other pull request in a bit and get that sorted.

I haven't written any new tests but will do that after I've sorted the other pull request.

mrghg commented 3 years ago

Looks good. There's a minor bug in the plotting routine, where the ability to select from the legend has gone. Let's not worry about it now, but that's going to annoy me, as I liked that feature! Will figure it out...

lukewestern commented 3 years ago

Ah, sorry about that. I'm still trying to get my head around Altair! If it comes to it, we could just remove the alt.vconcat() bit and have each plot with its own .display() and I think that would revert it back to how it was.

It will give each its own legend but I can live with that.