Skip to content

Problem using stl() on data from quantmod

5 messages · Wind, Gabor Grothendieck

#
With the following code, 

getSymbols("^GSPC")
xx<-as.ts(GSPC[,4])
xx<-na.approx(xx)
plot(stl(log(xx),s.window="period"))

There is an error:
Error in stl(log(xx), s.window = "period") : 
  only univariate series are allowed
ts [1:724, 1] 7.26 7.26 7.25 7.25 7.25 ...
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr "GSPC.Close"
 - attr(*, "tsp")= num [1:3] 13516 14239     1

It seems that the structure of xx is a little complicated.   But I still don't know how to trim it to the simplest ts format.

Regards,
Wind
#
Try this:

library(quantmod)
getSymbols("IBM")
xx <- ts(IBM, freq = 250)[, 4]
xx <- na.approx(xx)
plot(stl(log(xx), s.window = "period"))
On Mon, Dec 29, 2008 at 8:45 AM, Wind <windspeedo at qq.com> wrote:
#
ts(IBM, freq = 250)[, 4]
makes stl() OK.

I wonder the purpose of freq=250.   If IBM indeed contains different number
of data each year, say, 255 data one year and 252 data for another, is it
still propriate to use freq=250?

I tried to set freq=1 while using start to specify the start date.   But
don't know how to set start to a specific date.   

Thanks Gabor.

Regards,
Wind
Gabor Grothendieck wrote:

  
    
#
stl requires that a fixed frequency be specified.
On Mon, Dec 29, 2008 at 10:30 AM, Wind2 <windspeedo at qq.com> wrote:
#
It seems that I should learn more on freq to understand stl() better.
Thanks Gabor.

Regards,
Wind
Gabor Grothendieck wrote: