Closed hntd187 closed 8 years ago
Hey, I'm glad that you are interesting in contributing!
I had similar issues with the original R and Fortran code when originally putting this together, so the approach here was to basically start fresh, only referencing the paper (http://www.wessa.net/download/stl.pdf).
From reading the code though, I believe that the R code does cycle subseries weighted mean smoothing on the seasonal component after the outer loop terminates (if periodic is true). I added a comment in STLDecomposition.java about this with the snippet from R code, but just haven't tried it out yet - feel free to take a crack at it if you agree that's the right idea. The weightedMeanSmooth
method should help here. I think this might be the last thing that need to be done for parity with R code, but not sure.
Regarding the pull request, I want to keep the dependencies in main as light as possible (basically only math3) such that this code can be trivially contributed to math3, once it becomes more robust and tested.
Could you decouple the plotting code from STLResult, change the scope of the plotting library to "test", and create another class in the test package (e.g. STLPlotter.java)?
Also, I've been thinking about how to test this, like what would expected output be for various inputs that's acceptable by the paper's (or community's) standards. I suppose we could use output from the R function as a reference, but it would be nice if we could come up with something a little more rigorous (e.g. f(x) = some_trend * sin(x), run function, get some_trend within some error bounds after running STL). Let me know if you have any ideas there, or feel free to create another pull request.
Thanks, -Greg
Hey Greg,
I updated and refactored out what you asked into the STLPlotter class and updated the dependencies, so it should be inline with your suggestions. Could you perhaps tell me your style settings so I can not maul your code on the diff because I use a very different style settings? I'm gonna try and look at the weighted mean stuff and see what I can't crack.
Cool, looks good to me. I usually use the Google Java style (https://google.github.io/styleguide/javaguide.html), and have some checkstyle configuration sitting around. I'll add that to this repo in a couple minutes and set up the maven plugin.
Hey Stephen, I've created issue #2 to address the post smoothing. We can continue the discussion there.
Hi, I saw you uploaded this pretty recently so it looks like I am not the only one who is working on something like this.
Basically, I have some code with the R implementation of stl, but converting it to java has been a pain since the original fortran code is very difficult to understand and the R documentation is very confusing about what it actually does. Apparently it doesn't actually use Loess smoothing when specifying periodic instead of a window, but I basically have no idea how to reproduce the results from that. Even this code in it's current form doesn't produce results equivalent to stl with periodic turned on.
Either way, I'd like to contribute to this effort where I can, so I started by integrating the plotting ability for you in a manner as close to the R implementation as possible plus I added the trend over series as you put in your python script. These 2 implementation should create equal graphs, but I created this to hopefully open up a dialog about helping with this and where I can contribute. Thanks.
There are 3 overloaded versions of plot in the STLResults
I also added the inner class to STLResult for the plot generation. I'd like to add some more customization when I get the time but for now this produces good results.
Finally, my formatting seems messed up in comparison to yours, sorry about that, if you could give me your java style I can update the pull request with the proper style.
Thanks