Hi How would I analyse time series with - different lengths (i.e. one has 9 entries and the other has 14 entries) - different frequency (i.e. dates are random - no repeated length) - multiple values for the same time entry (e.g. 2009-10-23 below) i.e. my data takes the form: 1st time series 2009-10-07 0.009378 2009-10-19 0.014790 2009-10-23 -0.005946 2009-10-23 0.009096 2009-11-08 0.004189 2009-11-10 -0.004592 2009-11-17 0.009397 2009-11-24 0.003411 2009-12-02 0.003300 2010-01-15 0.010873 2010-01-20 0.010712 2010-01-20 0.022237 2nd time series 2009-09-23 0.076253 2009-10-07 0.039255 2010-02-17 0.039045 2010-03-09 0.024201 2010-03-25 -0.039810 2010-04-13 -0.012428 I am unable to get any functions to work. A simple plot would be nice! Thanks. -- View this message in context: http://r.789695.n4.nabble.com/Time-Series-tp2528444p2528444.html Sent from the R help mailing list archive at Nabble.com.
On Mon, Sep 6, 2010 at 10:24 AM, trb1 <thomasrbolton at yahoo.co.uk> wrote:> > Hi > > How would I analyse time series with > - different lengths (i.e. one has 9 entries and the other has 14 entries) > - different frequency (i.e. dates are random - no repeated length) > - multiple values for the same time entry (e.g. 2009-10-23 below) > > i.e. my data takes the form: > 1st time series > > 2009-10-07 ? ? ?0.009378 > 2009-10-19 ? ? ?0.014790 > 2009-10-23 ? ? ?-0.005946 > 2009-10-23 ? ? ?0.009096 > 2009-11-08 ? ? ?0.004189 > 2009-11-10 ? ? ?-0.004592 > 2009-11-17 ? ? ?0.009397 > 2009-11-24 ? ? ?0.003411 > 2009-12-02 ? ? ?0.003300 > 2010-01-15 ? ? ?0.010873 > 2010-01-20 ? ? ?0.010712 > 2010-01-20 ? ? ?0.022237 > > 2nd time series > > 2009-09-23 ? ? ?0.076253 > 2009-10-07 ? ? ?0.039255 > 2010-02-17 ? ? ?0.039045 > 2010-03-09 ? ? ?0.024201 > 2010-03-25 ? ? ?-0.039810 > 2010-04-13 ? ? ?-0.012428 > > I am unable to get any functions to work. > A simple plot would be nice! >Try this. We read in each series taking the last point in the event that there are multiple points with the same date. Then we plot each. If we wish to plot them on the same plot then we merge each series (for producing points) together with linear interpolations of both series (for producing lines) and plot. Lines1 <- "2009-10-07 0.009378 2009-10-19 0.014790 2009-10-23 -0.005946 2009-10-23 0.009096 2009-11-08 0.004189 2009-11-10 -0.004592 2009-11-17 0.009397 2009-11-24 0.003411 2009-12-02 0.003300 2010-01-15 0.010873 2010-01-20 0.010712 2010-01-20 0.022237" Lines2 <- "2009-09-23 0.076253 2009-10-07 0.039255 2010-02-17 0.039045 2010-03-09 0.024201 2010-03-25 -0.039810 2010-04-13 -0.012428" library(zoo) z1 <- read.zoo(textConnection(Lines1), aggregate = function(x) tail(x, 1)) z2 <- read.zoo(textConnection(Lines2), aggregate = function(x) tail(x, 2)) plot(z1, type = "o") plot(z2, type = "o") # or together on the same plot zz <- merge(z1, z2) zz <- merge(z1, z2, na.approx(zz, na.rm = FALSE)) plot(zz, type = c("p", "p", "l", "l"), screen = 1:2) -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
Thank you very much for your post. Your answer has been very helpful. Is it possible to merge >2 time series? -- View this message in context: http://r.789695.n4.nabble.com/Time-Series-tp2528444p2528584.html Sent from the R help mailing list archive at Nabble.com.
On Mon, Sep 6, 2010 at 11:56 AM, trb1 <thomasrbolton at yahoo.co.uk> wrote:> > Thank you very much for your post. > Your answer has been very helpful. > Is it possible to merge >2 time series? >zz is my posted code was formed by merging two univariate and one multivariate series. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
Hi list, I have a set of data which I want to use time series analysis in R in order to forecast the value for future. I know there are some R functions, but not sure how to use them. Would you please help me if you are familiar with time series in R? I want to get value for Nov 2012 using the following data. thanks Alireza time value Mar-80 72 Jun-80 77.4 Sep-80 81.9 Dec-80 81 Mar-81 80.1 Jun-81 77.4 Sep-81 67.5 Dec-81 68.4 Mar-82 55.8 Jun-82 42.3 Sep-82 32.4 Dec-82 22.5 Mar-83 25.2 Jun-83 32.4 Sep-83 27 Dec-83 36 Mar-84 33.3 Jun-84 41.4 Sep-84 20.7 Dec-84 18.9 Mar-85 11.7 Jun-85 15.3 Sep-85 9 Dec-85 13.5 Mar-86 17.1 Jun-86 16.2 Sep-86 24.3 Dec-86 28.8 Mar-87 33.3 Jun-87 41.4 Sep-87 46.8 Dec-87 61.2 Mar-88 68.4 Jun-88 74.7 Sep-88 58.5 Dec-88 57.6 Mar-89 63.9 Jun-89 52.2 Sep-89 50.4 Dec-89 50.4 Mar-90 42.3 Jun-90 38.7 Sep-90 26.1 Dec-90 25.2 Mar-91 27 Jun-91 18.9 Sep-91 15.3 Dec-91 15.3 Mar-92 16.2 Jun-92 17.1 Sep-92 13.5 Dec-92 15.3 Mar-93 18.9 Jun-93 15.3 Sep-93 19.8 Dec-93 27.9 Mar-94 33.3 Jun-94 51.3 Sep-94 40.5 Dec-94 60.3 Mar-95 59.4 Jun-95 58.5 Sep-95 47.7 Dec-95 57.6 Mar-96 45.9 Jun-96 37.8 Sep-96 30.6 Dec-96 37.8 Mar-97 40.5 Jun-97 34.2 Sep-97 28.8 Dec-97 26.1 Mar-98 26.1 Jun-98 15.3 Sep-98 11.7 Dec-98 10.8 Mar-99 10.8 Jun-99 13.5 Sep-99 22.5 Dec-99 32.4 Mar-00 39.6 Jun-00 32.4 Sep-00 35.1 Dec-00 27 Mar-01 29.7 Jun-01 35.1 Sep-01 34.2 Dec-01 42.3 Mar-02 51.3 Jun-02 61.2 Sep-02 61.2 Dec-02 57.6 Mar-03 53.1 Jun-03 45 Sep-03 48.6 Dec-03 54.9 Mar-04 61.2 Jun-04 63 Sep-04 71.1 Dec-04 78.3 Mar-05 70.2 Jun-05 73.8 Sep-05 77.4 Dec-05 75.6 Mar-06 76.5 Jun-06 72.9 Sep-06 76.5 Dec-06 74.7 Mar-07 72 Jun-07 72 Sep-07 64.8 Dec-07 60.3 Mar-08 43.2 Jun-08 40.5 Sep-08 30.6 Dec-08 29.7 Mar-09 24.3 Jun-09 23.4 Sep-09 20.7 Dec-09 25.2 Mar-10 38.7 Jun-10 32.4 Sep-10 42.3 [[alternative HTML version deleted]]
Unless you tell us what model or what forecasting technique you want to use, it seems to me that this is more a question about Statistics than about using R. Best, Giovanni Petris On Mon, 2010-09-27 at 23:02 +0100, Dr. Alireza Zolfaghari wrote:> Hi list, > I have a set of data which I want to use time series analysis in R in order > to forecast the value for future. I know there are some R functions, but not > sure how to use them. Would you please help me if you are familiar with time > series in R? I want to get value for Nov 2012 using the following data. > > thanks > Alireza > > time value Mar-80 72 Jun-80 77.4 Sep-80 81.9 Dec-80 81 Mar-81 80.1 Jun-81 > 77.4 Sep-81 67.5 Dec-81 68.4 Mar-82 55.8 Jun-82 42.3 Sep-82 32.4 Dec-82 22.5 > Mar-83 25.2 Jun-83 32.4 Sep-83 27 Dec-83 36 Mar-84 33.3 Jun-84 41.4 Sep-84 > 20.7 Dec-84 18.9 Mar-85 11.7 Jun-85 15.3 Sep-85 9 Dec-85 13.5 Mar-86 17.1 > Jun-86 16.2 Sep-86 24.3 Dec-86 28.8 Mar-87 33.3 Jun-87 41.4 Sep-87 46.8 > Dec-87 61.2 Mar-88 68.4 Jun-88 74.7 Sep-88 58.5 Dec-88 57.6 Mar-89 63.9 > Jun-89 52.2 Sep-89 50.4 Dec-89 50.4 Mar-90 42.3 Jun-90 38.7 Sep-90 26.1 > Dec-90 25.2 Mar-91 27 Jun-91 18.9 Sep-91 15.3 Dec-91 15.3 Mar-92 16.2 Jun-92 > 17.1 Sep-92 13.5 Dec-92 15.3 Mar-93 18.9 Jun-93 15.3 Sep-93 19.8 Dec-93 27.9 > Mar-94 33.3 Jun-94 51.3 Sep-94 40.5 Dec-94 60.3 Mar-95 59.4 Jun-95 58.5 > Sep-95 47.7 Dec-95 57.6 Mar-96 45.9 Jun-96 37.8 Sep-96 30.6 Dec-96 37.8 > Mar-97 40.5 Jun-97 34.2 Sep-97 28.8 Dec-97 26.1 Mar-98 26.1 Jun-98 15.3 > Sep-98 11.7 Dec-98 10.8 Mar-99 10.8 Jun-99 13.5 Sep-99 22.5 Dec-99 32.4 > Mar-00 39.6 Jun-00 32.4 Sep-00 35.1 Dec-00 27 Mar-01 29.7 Jun-01 35.1 Sep-01 > 34.2 Dec-01 42.3 Mar-02 51.3 Jun-02 61.2 Sep-02 61.2 Dec-02 57.6 Mar-03 53.1 > Jun-03 45 Sep-03 48.6 Dec-03 54.9 Mar-04 61.2 Jun-04 63 Sep-04 71.1 Dec-04 > 78.3 Mar-05 70.2 Jun-05 73.8 Sep-05 77.4 Dec-05 75.6 Mar-06 76.5 Jun-06 72.9 > Sep-06 76.5 Dec-06 74.7 Mar-07 72 Jun-07 72 Sep-07 64.8 Dec-07 60.3 Mar-08 > 43.2 Jun-08 40.5 Sep-08 30.6 Dec-08 29.7 Mar-09 24.3 Jun-09 23.4 Sep-09 20.7 > Dec-09 25.2 Mar-10 38.7 Jun-10 32.4 Sep-10 42.3 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.