[R] partial analisys of a time series

arun smartpink111 at yahoo.com
Tue Dec 4 14:02:20 CET 2012


HI,
I am getting an error message:
l.blist<-lapply(blist,HoltWinters)
#Error in decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal) : 
 # time series has no or less than 2 periods
A.K.



----- Original Message -----
From: PIKAL Petr <petr.pikal at precheza.cz>
To: Antonio Silva <aolinto.lst at gmail.com>; "R-help at r-project.org" <R-help at r-project.org>
Cc: 
Sent: Tuesday, December 4, 2012 5:07 AM
Subject: Re: [R] partial analisys of a time series

Hi

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Antonio Silva
> Sent: Tuesday, December 04, 2012 10:26 AM
> To: R-help at r-project.org
> Subject: [R] partial analisys of a time series
> 
> Dear list members
> 
> I want to analyze separately the months of a time series. In other
> words, I want to plot and fit models for each month separately.
> 
> Taking the example of
> http://a-little-book-of-r-for-time-
> series.readthedocs.org/en/latest/src/timeseries.html
> 
> births <- scan("http://robjhyndman.com/tsdldata/data/nybirths.dat")
> birthstimeseries <- ts(births, frequency=12, start=c(1946,1))
> birthstimeseries
> plot.ts(birthstimeseries)
> birthstimeseriesHW <- HoltWinters(birthstimeseries)
> plot(birthstimeseriesHW)
> 
> How to proceed the plotting and HoltWinters smoothing considereing only
> Januarys, Februarys, etc. separately.

Split your data by months to a list, use lapply.

using zoo package

blist <-split(birthstimeseries, months(as.Date(birthstimeseries)))
l.blist <- lapply(blist, HoltWinters)

Regards
Petr





> 
> Thanks in advance.
> 
> Antonio Olinto
> 
>     [[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.

______________________________________________
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.





More information about the R-help mailing list