Perhaps mydata is a matrix or matrix-like object, and you should create one ts object for each column? -- Sent from my phone. Please excuse my brevity.
On March 13, 2018 7:25:31 AM PDT, JEFFERY REICHMAN <reichm...@sbcglobal.net> wrote: >R Help Community > >I'm trying to understand time series (TS) objects. Thought I >understood but recently have run into a series of error messages that >I'm not sure how to handle. I have 15 years of quarterly data and I >typically create a TS object via something like... > >data.ts <- ts(mydata, start = 2002, frequency = 4) > >this create a matric as opposed to a vector object as I receive a >univariate error when I try to decompose the data using the STL >function > >data.stl <- stl(data.ts, "periodic") >Error in stl(data.ts, "periodic") : only univariate series are allowed > >ok so > >is.vector(data.ts) >[1] FALSE > >so to convert to a vector I'll use >data.ts <- as.vector(data.ts) > >but then I lose the frequency as the periods as the data becomes >frequency = 1 >data.ts <- stl <- stl(data.ts, "periodic") >Error in stl(data.ts, "periodic") : > series is not periodic or has less than two periods. > >So am I missing a parameter or is there a more general/proper way to >create a time series object? First time I've run into this problem . I >can always decompose via an alternative methods so there are work >arounds. But just trying to understand what I'm not doing >programmatically at this point. > >Jeff Reichman > >______________________________________________ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >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@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.