[R-SIG-Finance] plotting stl with time series data

Joshua Ulrich josh.m.ulrich at gmail.com
Tue Jan 17 03:14:17 CET 2012


Please don't cross-post:
http://stackoverflow.com/questions/8888237/plotting-stl-with-time-series-data
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com



On Mon, Jan 16, 2012 at 2:03 PM, financial engineer
<fin_engr at hotmail.com> wrote:
>
> hi,
>
> I am trying to use stl to get a breakdown of the seasonal and trend in my timeseries data. I have tick data, and I have created a ts object.
>
> I ran a SQL query to get the data in the below form
>>x
>            V1                               V2
> 49995  2010-07-09 1341        9610
> 49996  2010-07-09 1341        9610
> 49997  2010-07-09 1342        9615
> 49998  2010-07-09 1342        9615
> 49999  2010-07-09 1342        9615
>
> and I converted it into ts by running the following:
>> xt<-ts(x[,2])
>>xt
> [99975] 9285 9285 9285 9285 9290 9290 9290 9290 9290 9290 9290 9290 9290 9290
> [99989] 9290 9290 9290 9290 9285 9285 9290 9290 9290 9290 9290
>
>> is.ts(xt)
> [1] TRUE
>
> now, when I try to plot the stl, I get the following error:
>>require(graphics)
>> plot(drg<-stl(log(xt), "per"))
> Error in plot(drg <- stl(log(xt), "per")) :
>  error in evaluating the argument 'x' in selecting a method for function 'plot'
>
> I even tried the following:
>> plot(drg<-stl(log(xt), s.window=21))
> Error in plot(drg <- stl(log(xt), s.window = 21)) :
>  error in evaluating the argument 'x' in selecting a method for function 'plot'
>>
>
> any suggestion on how I can fix the error, to be able to see the breakdown of the different trend components...I suspect I need to create the ts object differently, but I am not quite clear how to do it.....I can create the xts object but I realize that doesn't work with stl.
>
>
>
>
>        [[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