[R] stl cycle sub-series plot
Dear R-people, I tried to build a seasonal cycle sub-series plot of my time series using: monthplot(nitrat.stl, choice=seasonal) However, I only get the horizontal lines of the mean values and not the vertical lines for each year. Can anybody help me? Sincerely, Anja -- * Dr. Anja Eggert Universität Rostock Institut für Biowissenschaften AG Angewandte Ökologie Albert-Einstein-Str. 3 18059 Rostock T: ++49 381 498 6094 F: ++49 381 498 6072 e-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] stl function
I want to apply the stl-function to decompose a time series (daily measurements over 22 years) into seasonal component, trend and residuals. I was able to get the diagrams. However, I could not find out what are the equations behind it. I.e. it is probably not an additive or multiplicative combination of season (as sin and cos-functions) and a linear trend? Furthermore, what are the grey bars on the right hand side of the diagrams? I would appreciate very much to receive some information or maybe a good reference. Thank you very much, Anja -- * Dr. Anja Eggert Universität Rostock Institut für Biowissenschaften AG Angewandte Ökologie Albert-Einstein-Str. 3 18059 Rostock T: ++49 381 498 6094 F: ++49 381 498 6072 e-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] stl function
On Tue, 2007-02-27 at 15:55 +0100, Anja Eggert wrote: I want to apply the stl-function to decompose a time series (daily measurements over 22 years) into seasonal component, trend and residuals. I was able to get the diagrams. However, I could not find out what are the equations behind it. I.e. it is probably not an additive or multiplicative combination of season (as sin and cos-functions) and a linear trend? Furthermore, what are the grey bars on the right hand side of the diagrams? I would appreciate very much to receive some information or maybe a good reference. Thank you very much, Anja ?stl tells you all you need to know to answer this, including the reference to the academic publication that describes the method. ?plot.stl tells you that the grey bars are range bars - they are used to assess the relative magnitude of various decomposed components. G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] stl and the relative scale data-seasonal
I'm not sure I understand what you want. However, I will suppose I wanted essentially the same image as plot(stl..) but with individual control over ylim for each of the 4 plots. In that case, I might make a local copy of the actual plot function using 'getAnywhere(plot.stl)' and modify it. I got to the point by noting that plot in most cases calls 'UseMethod(plot)'. This suggested I check 'methods(plot)'. The response to this included 'plot.stl', which would be called by 'UseMethod(plot)' whenever the first argument of 'plot' was of class 'stl'. Then I'd modify my local copy of 'plot.stl' to produce what I wanted (using 'debug' to walk through the code line by line if my modifications didn't work right and I didn't understand immediately why). This may be as much work as extracting all the components and plot 4 separate figures, but I see no simpler way. Hope this helps. Spencer Graves p.s. By 'debug' here, I mean the 'debug' in the 'base' package, not the 'debug' package, which I've never used but is doubtless more powerful (though may also require more effort and thought from the user). For more information on debug{base}, I suggest you consult the documentation and perhaps the archives. RSiteSearch(graves debug) produced 127 hits for me just now. The most interesting for you among the first few might be http://finzi.psych.upenn.edu/R/Rhelp02a/archive/79251.html;. Berta wrote: I am trying to plot the time series decomposition using plot(stl..). Eventhough I understand why the scale of the 4 plots is better to be unequal, I would like to plot all 4 in the same scale (otherwise interpretation at a simple look may be misleading). Is there a way I could do so (easier than extracting all the components and plot 4 separate figures using 4 plot-comands)? Thanks a lot in advance. Berta. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] stl and the relative scale data-seasonal
I am trying to plot the time series decomposition using plot(stl..). Eventhough I understand why the scale of the 4 plots is better to be unequal, I would like to plot all 4 in the same scale (otherwise interpretation at a simple look may be misleading). Is there a way I could do so (easier than extracting all the components and plot 4 separate figures using 4 plot-comands)? Thanks a lot in advance. Berta. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] stl function
Hi, I have a monthly time series with missing values and I would use stl function to identify seasonality. I tried all settings of na.action but the result is the same: stl(tm245,s.window=11, na.action=na.pass) Error in stl(tm245, s.window = 11, na.action = na.pass) : NA/NaN/Inf in foreign function call (arg 1) Can you help me? Thanks Andrea Toreti [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] stl function
stl does this internally: x - na.action(as.ts(x)) so stl(x, s.window, na.action = f) is the same as stl(f(as.ts(x)), s.window) e.g. nottem[25] - NA # nottem is a built in data set in R stl(nottem, per) # error stl(nottem, per, na.action = na.contiguous) library(zoo) stl(nottem, per, na.action = na.locf) stl(nottem, per, na.action = na.approx) Whether any of these makes sense is another matter. On 4/26/06, Andrea Toreti [EMAIL PROTECTED] wrote: Hi, I have a monthly time series with missing values and I would use stl function to identify seasonality. I tried all settings of na.action but the result is the same: stl(tm245,s.window=11, na.action=na.pass) Error in stl(tm245, s.window = 11, na.action = na.pass) : NA/NaN/Inf in foreign function call (arg 1) Can you help me? Thanks Andrea Toreti [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] stl()
Hello, anyone got an idea on how to use stl() so that the remainder eventually becomes white noise? i used stl repeatedly but there is autocorrelation in the remainder that i can't get rid of. os: linux suse9.3 Sebastian Leuzinger Institute of Botany, University of Basel Schönbeinstr. 6 CH-4056 Basel ph0041 (0) 61 2673511 fax 0041 (0) 61 2673504 email [EMAIL PROTECTED] web http://pages.unibas.ch/botschoen/leuzinger __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] stl()
Hi, maybe residuals are autocorreleted, you could you use ARIMA models. See arima() in R to fit an ARIMA model. Regards, Vito Sebastian.Leuzinger at unibas.ch wrote: Hello, anyone got an idea on how to use stl() so that the remainder eventually becomes white noise? i used stl repeatedly but there is autocorrelation in the remainder that i can't get rid of. os: linux suse9.3 Sebastian Leuzinger Institute of Botany, University of Basel Schönbeinstr. 6 CH-4056 Basel ph0041 (0) 61 2673511 fax 0041 (0) 61 2673504 email Sebastian.Leuzinger at unibas.ch web http://pages.unibas.ch/botschoen/leuzinger Diventare costruttori di soluzioni Became solutions' constructors The business of the statistician is to catalyze the scientific learning process. George E. P. Box Statistical thinking will one day be as necessary for efficient citizenship as the ability to read and write H. G. Wells Top 10 reasons to become a Statistician 1. Deviation is considered normal 2. We feel complete and sufficient 3. We are 'mean' lovers 4. Statisticians do it discretely and continuously 5. We are right 95% of the time 6. We can legally comment on someone's posterior distribution 7. We may not be normal, but we are transformable 8. We never have to say we are certain 9. We are honestly significantly different 10. No one wants our jobs Visitate il portale http://www.modugno.it/ e in particolare la sezione su Palese http://www.modugno.it/archivio/palesesanto_spirito/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] stl,package=stats
Pedro Rodrigues [EMAIL PROTECTED] wrote: On Sun, 2004-07-18 at 18:38, bob mccall wrote: Greetings: I'm using the time series decomposition routine stl from the package stats. But how do I get the results into a vector to work with them? example: data(AirPassengers) m-stl(AirPassengers,per) print(m) This lists the output but can't figure out how to extract the individual series like seasonal, trend, irregular. # Seasonal as.vector(m$time.series[,1]) # Trend as.vector(m$time.series[,2]) # Remainder as.vector(m$time.series[,3]) Thanks, Bob - Thanks Pedro. This works! Bob - Vote for the stars of Yahoo!'s next ad campaign! [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] stl,package=stats
Greetings: I'm using the time series decomposition routine stl from the package stats. But how do I get the results into a vector to work with them? example: data(AirPassengers) m-stl(AirPassengers,per) print(m) This lists the output but can't figure out how to extract the individual series like seasonal, trend, irregular. Thanks, Bob - Vote for the stars of Yahoo!'s next ad campaign! [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] stl,package=stats
bob mccall wrote: Greetings: I'm using the time series decomposition routine stl from the package stats. But how do I get the results into a vector to work with them? example: data(AirPassengers) m-stl(AirPassengers,per) print(m) This lists the output but can't figure out how to extract the individual series like seasonal, trend, irregular. There are two ways: Either use str(m) to look at the structure of the object or read the help page ?stl which tells you that ... 'stl returns an object of class stl with components time.series a multiple time series with columns seasonal, trend and remainder.' ... I don't know whether there are any specific extractor methods, but to extract the decomposed seasonal values, you can simply write: m$time.series[,seasonal] Uwe Ligges Thanks, Bob - Vote for the stars of Yahoo!'s next ad campaign! [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] stl,package=stats
On Sun, 2004-07-18 at 18:38, bob mccall wrote: Greetings: I'm using the time series decomposition routine stl from the package stats. But how do I get the results into a vector to work with them? example: data(AirPassengers) m-stl(AirPassengers,per) print(m) This lists the output but can't figure out how to extract the individual series like seasonal, trend, irregular. # Seasonal as.vector(m$time.series[,1]) # Trend as.vector(m$time.series[,2]) # Remainder as.vector(m$time.series[,3]) Thanks, Bob - Vote for the stars of Yahoo!'s next ad campaign! [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] stl and NA
Hi, I try to figure out what the stl-function exactly do. I was reading the paper by Cleveland et al. (1990) and tested some features of stl (the ability to decompose time series with missing values and the robustness feature). I tried the following: data(co2) co2.na - co2 is.na(co2.na[c(50, 100)]) - TRUE plot(stl(co2.na, s.window = 12, na.action = na.exclude)) With the error message: Error in stl(co2.na, s.window = 12, na.action = na.exclude) : series is not periodic or has less than two periods The following works fine: plot(stl(co2, s.window = 12)) I had then a short look in the code of stl. Is it true that the argument na.action must be a generic function, one of ?na.fail? The help of stl: na.action action on missing values. (Mmmh, not really helpful) The other functions na.omit and na.pass do not what I was expecting?! plot(stl(co2.na, s.window = 12, na.action = na.omit)) Error in na.omit.ts(as.ts(x)) : time series contains internal NAs Is this feature correctly implemented? I do not found a bug report http://r-bugs.biostat.ku.dk/cgi-bin/R... So I assume that I'm missing something. How can I handle NAs in stl() correctly? Thanks for any hints and comments Thomas __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] STL- TimeSeries Decomposition
Dear R Helpers, Currently I'm working with the ts package of R and created a TimeSerie from pixels extracted from satellite imagery(S10 NDVI data, 10 daily composites). I'm trying to decompose this signal in different signals (seasonal and trend). When testing out the STL method is says = Only univariate timeseries are allowed, but the current Timeserie I'm using is univariate! = The problem is probably that this time series has to much noise so that it consequently gives the following error. plot(stl(Timeserie)) Error in stl(Timeserie) : only univariate series are allowed. I also import the data as an ts object. A solution would be to eliminate the noise (sensor and atmospheric) with a filter (kalman/ holt-Winters/TsSmooth? Or FFT.) or the BISE method in R? Is the BISE (Best index slope extraction) function already programmed in R I couldn't find it? Much appreciated, Jan *** Jan Verbesselt Research Associate Lab of Geomatics and Forest Engineering K.U. Leuven Vital Decosterstraat 102. B-3000 Leuven Belgium Tel:+32-16-329750 Fax: +32-16-329760 http://perswww.kuleuven.ac.be/~u0027178/VCard/mycard.php?name=janv __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] STL- TimeSeries Decomposition
On Wed, 30 Jul 2003, Jan Verbesselt wrote: Dear R Helpers, Currently I'm working with the ts package of R and created a TimeSerie from pixels extracted from satellite imagery(S10 NDVI data, 10 daily composites). I'm trying to decompose this signal in different signals (seasonal and trend). When testing out the STL method is says = Only univariate timeseries are allowed, but the current Timeserie I'm using is univariate! = The problem is probably that this time series has to much noise so that it consequently gives the following error. plot(stl(Timeserie)) Error in stl(Timeserie) : only univariate series are allowed. I also import the data as an ts object. No, the problem *is* that the time series is a matrix, and so not univariate. Try dim(Timeserie) to see. If it has one column (as I suspect), you need to remove that (dim(Timeserie) - NULL). A solution would be to eliminate the noise (sensor and atmospheric) with a filter (kalman/ holt-Winters/TsSmooth? Or FFT.) or the BISE method in R? Is the BISE (Best index slope extraction) function already programmed in R I couldn't find it? I've never even heard of it. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help