Giter Site home page Giter Site logo

stlplus's Introduction

stlplus

Build Status CRAN

png

This package contains enhancements to the Seasonal Trend Decomposition using Loess (STL) implementation that comes with base R, stl().

Here are some of the added features over stl():

  • Can handle NA values
  • Higher order loess smoothing (more than just local constant and linear)
  • Automated parameter choices for local quadratic
  • Frequency component smoothing beyond seasonal and trend
  • Plot methods for diagnostics

For (very) experimental inference, prediction, and variance reduction at endpoints, see the operator package.

References

Installation

CRAN:

install.packages("stlplus")

Github:

devtools::install_github("hafen/stlplus")

License

This software is released under the BSD license. Please read the license document.

stlplus's People

Contributors

hafen 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stlplus's Issues

forecast

I'm trying to reconstruct the original series and use it for t+1 prediction.

Anyway to use stlplus like STL with forecast package like forecast.stl ?

Trend() returning incorrect result

In writing the CV procedure I've made extensive use of the trend() method for the STL object created. Unfortunately, it seems like it produces the incorrect result. See for example:

temp<-c(-5.98,-8.15,-5.48,-2.405,-2.17,-5.985,-6.52,-5.06,-4,-6.83,-6.35,-3.63,-4.75,-7.5,-8.75,-7.42,-7.45,-8.09,-7.86,-5.91,-5.79,-8.66,-9.16,-3.575,-3.875,-7.01,-8.5,-8.07,-8.515,-10.3,-8.45,-8.67,-9.16,-9.91,-9.815,-9.12,-12.735,-14.3,-12.77,-4.66,-5.14,-7.25,-8.465,-6.525,-9.46,-11.3,-9.5,-5.86,-6.48,-8.725,-8.53,-6.73,-7.32,-7.3,-7.475,-6.575,-6.77,-7.35,-6.97,-2.85,-5.41,-6.65,-5.92,-5.08,-4.435,-6.525,NA,-5.37,-5.18,-7.575,NA,-3.7,-5.77,-9.355,-9.245,-5.98,-7.87,-9.705,-9.635,-6.795)
start<- c(1996,1); 
temp.ts <- ts(tempdat, start=start, frequency = 4)

stlobj <- stlplus(temp.ts, s.window=55, s.degree=1,
                  t.window=4,
                  t.degree=2,fc.window=10)

plot(temp.ts)
plot(stlobj)
plot(ts(trend(stlobj),start= start,
         frequency = 4))

Trend seems to return something that looks much more like the original time series than the trend line shown in the plot of the stl object. I'm sure this is just a small mistake in the method, but I'm not sure where it might be.

Interest in Implementing Cross Validation?

Hi, is there any interest in implementing cross validation for estimating missing values in the package? I have a problem where I had a time steps missing at random throughout my time series, and because of the number of time series I have to estimate the NA's for, it seemed to make the most sense to automatically perform parameter selection through cross validation.

Anyways long story short I've written up methods for K-fold and Monte Carlo cross validation to work with STLplus and I've also written a function to perform a grid search not so different than in the Scikit learn in python. If you're interested I can paste the code here, or if it's not really appropriate for the package itself I can submit my code as an answer to a self-made question on Stack Exchange.

Best,
Matt

PS: the function hasn't been super optimized yet or user-proofed, but I figured I'd include that iff it would be used by general people.

Handling NaN values

Hi,
I was searching about decompose functions that could handle NaNs and found yours, but it is implemented in R, would be possible for you to give me a brief explanation how you handle the NaNs so i can understand how it works, use it and also try to implement in python?
Thanks

Default value of t.window

Hello,
first of all I would like to thank you for creating this package. I find the diagnostic plots of the stlplus package very useful. I'm writing to you because the default value of t.window seems unusual to me. I am not sure if this is done on purpose for some reasons I don't know or if it is just an oversight.

According to the original paper "STL: A Seasonal-Trend Decomposition Procedure Based on Loess" by Cleveland et al., t.window should be set to the smallest odd integer greater or equal to(1.5*period) / (1-(1.5/s.window)(see pages 16-20 and 28). This fact is written in the documentation of the stlplus() function of the stlplus package too:

t. window: If NULL, the default, nextodd(ceiling((1.5*period) / (1-(1.5/s.window)))), is taken.

However the default value of t.windows seems to be different:

fit = stlplus(co2, s.window = 35)
fit$pars$win
  s.window t.window l.window
       35       17       13

The time series is monthly so I would expect a default t.window value equal to 19 instead of 17.

> fit = stlplus(co2, s.window = 15)
> fit$pars$win
  s.window t.window l.window
      15       19       13

And here, I would expect a t.window equal to 21 instead of 19.

Am I missing something?

Handling Missing Values

Hello,

I would like to know how the issue with Nan values has been handled within the code. By ignoring the missing data or simply by interpolation?

Regards,

stlplus-java

Hi,
I had a java implementation for your code, it may help others.
and I compare the java-implementation and the r-implementation, bias is very small.

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.