[R-SIG-Finance] hourly time series

R. Michael Weylandt michael.weylandt at gmail.com
Wed Mar 14 14:11:00 CET 2012


I think you are interpreting your frequency argument incorrectly and
thus R is giving you an error message because you are asking for
seasonal trends but giving only one observation per "season" -- it's
rather subtle: as the help page says,

frequency -- the number of observations per unit of time.

Note that this works,

wind_ts <- ts(cumsum(rnorm(8760)), start = 1, frequency = 24) # E.g.,
the relevant time scale is "daily" and you have 24 obs per day
(hourly)
decompose(wind_ts)

This would be for a phenomenon that reoccurs daily: I'm not sure if a
single monsoon season (I think there's only one a year but I don't
really know Indian climatology so well) will give you sufficient power
for a statistically significant result, but you can cross that bridge
when you get to it.

Hope this helps,

Michael

PS -- The ts class is generally considered a necessary evil around
here because of things like that ;-)

On Wed, Mar 14, 2012 at 5:45 AM, Advait Godbole <advaitgodbole at gmail.com> wrote:
> Dear all,
>
> I am new to this list and I first posted this query on the r-sig-geo forum,
> apologies for the cross-post. My question is not related to finance,
> however I am sure many users here will have experience with time series
> analysis and would be able to provide insight.
>
> I have one year's worth of hourly data, starting from 1st April 2010 and
> ending on 31st March 2011. I would like to perform time series analysis on
> it. New to time series analysis and not having used "ts" before, I am
> having trouble setting it up to correctly represent the data. I have R
> reading in the time series via:
> *wind_ts <- ts(wind.MH,start=1,frequency=1)*
>
> where "wind.MH" is a 8760x1 matrix object. I then tried to decompose the
> time series with the following error:
> *wind_ts_components <- decompose(wind_ts)*
> *Error in decompose(wind_ts) : time series has no or less than 2 periods*
>
> The dataset is the hourly wind generation for Maharashtra, India and has
> some seasonality associated with the Indian monsoon. Ultimately, this is
> what I would like to identify. I imagine that correctly setting the "start"
> and "frequency" parameters is necessary to be able to parse the dataset
>  into months and seasons. Someone suggested I use the "timetools" package
> instead but I havent had the chance to do so.
>
> I would greatly appreciate help on how to handle this and any leads on time
> series analysis for hourly data in general.
>
> Regards,
>
> --
> advait godbole
> analyst, prayas energy group
> pune, india
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.



More information about the R-SIG-Finance mailing list