Re: [R] how to calculate the statistics of a yearly window with a rolling step as 1 day?
This doesn't work becaues the rollappy is non-overlapping. My rolling step is 1-day and rolling window is 1-year, so there is 364 days overlapping. -- View this message in context: http://r.789695.n4.nabble.com/how-to-calculate-the-statistics-of-a-yearly-window-with-a-rolling-step-as-1-day-tp3891404p3897922.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] how to calculate the statistics of a yearly window with a rolling step as 1 day?
On Wed, Oct 12, 2011 at 9:12 AM, ecoc liting...@gmail.com wrote: This doesn't work becaues the rollappy is non-overlapping. My rolling step is 1-day and rolling window is 1-year, so there is 364 days overlapping. Its not the case that rollapply is non-overlapping. rollapply by default calls the function on a stretch of data moving ahead by 1 each time so it does overlap. Also you can use by= to cause it to move ahead by some other number if you wish. Also by setting by= appropriately you can get it to not overlap at all if you wish. Also depending on what your problem is you may be able to handle variations in the function itself, e.g. removing NAs. I suggest you give a small reproducible example showing what you have and what you want in order to clarify. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org 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] how to calculate the statistics of a yearly window with a rolling step as 1 day?
Hope someone can help me here. I have a daily time series, say 2003-02-01 2003-02-03 2003-02-07 2003-02-09 2003-02-14 .. 2004-02-01 2004-02-04 0.4914798 -1.1857653 -1.6982844 -0.3559572 -0.2333087 ... 0.44553-0.45222 I need to calculate the statistics for the overlapping rolling yearly window with rolling step as 1 day so for each of the intervals: (2003-02-01 ~ 2004-02-01), (2003-02-03 ~ 2004-02-04), i need to calculate some statistics. Could you please help me out how to extract these intervals? Right now I am using index. But since the dates doesn't match exactly, I have to do it like: a(index(a)=index(b) index(a)=index(b)+365), which is very time-consuming since it's a long time series. Could someone help me? Really appreicate!!! -- View this message in context: http://r.789695.n4.nabble.com/how-to-calculate-the-statistics-of-a-yearly-window-with-a-rolling-step-as-1-day-tp3891404p3891404.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org 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] how to calculate the statistics of a yearly window with a rolling step as 1 day?
On Mon, Oct 10, 2011 at 2:55 PM, ecoc liting...@gmail.com wrote: Hope someone can help me here. I have a daily time series, say 2003-02-01 2003-02-03 2003-02-07 2003-02-09 2003-02-14 .. 2004-02-01 2004-02-04 0.4914798 -1.1857653 -1.6982844 -0.3559572 -0.2333087 ... 0.44553 -0.45222 I need to calculate the statistics for the overlapping rolling yearly window with rolling step as 1 day so for each of the intervals: (2003-02-01 ~ 2004-02-01), (2003-02-03 ~ 2004-02-04), i need to calculate some statistics. Could you please help me out how to extract these intervals? Right now I am using index. But since the dates doesn't match exactly, I have to do it like: a(index(a)=index(b) index(a)=index(b)+365), which is very time-consuming since it's a long time series. Could someone help me? Really appreicate!!! Fill in the missing days with NAs using zoo FAQ 15 or otherwise and then use rollapply(z, 365, f, ...whatever...) such that your function f first removes any NAs. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org 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.