decompose wants frequency(Y) to be more than 1 - it really wants an integer frequency so it can return a vector of that length containing the repeating pattern (the "figure").
frequency(Y) is 1/3600 so you get the error (which might be better worded): > plot(decompose(Y)) Error in decompose(Y) : time series has no or less than 2 periods > frequency(Y) [1] 0.0002777778 Use a ts object and make the frequency relative to the period of interest (e.g., 24 for hourly data if you are interested in the daily pattern). Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Mar 30, 2016 at 5:37 PM, Ryan Utz <utz.r...@gmail.com> wrote: > Bill, Josh, and Bert, > > Thanks for your responses. I still can't quite get this when I use actual > dates. Here's an example of what is going wrong: > > X=as.data.frame(1:6000) > X[2]=seq.POSIXt(ISOdate(2015,11,1),by='hour',length.out=6000) > X[3]=sample(100,size=6000,replace=T) > > Y=xts(X[,3],order.by=X[,2]) > decompose(Y) > > Z=ts(X[,2],frequency=24*365) > plot(decompose(Z)) > > When I specify an actual date/time (rather than just a number as Bill > posited), it does not like anything short of a year. This seems like I'm > overlooking something obvious, but I can't get this for the life of me... > > Thanks for your time, > r > > > On Wed, Mar 30, 2016 at 1:03 PM, William Dunlap <wdun...@tibco.com> wrote: > >> You said you specified frequency=96 when you constructed the time >> series, but when I do that the decomposition looks reasonable: >> >> > time <- seq(0,9,by=1/96) # 15-minute intervals, assuming time unit is >> day >> > measurement <- sqrt(time) + 1/(1.2+sin(time*2*pi)) + >> rnorm(length(time),0,.3) >> > plot(decompose(ts(measurement, frequency=96))) >> >> How is your code different from the above? >> >> >> >> Bill Dunlap >> TIBCO Software >> wdunlap tibco.com >> >> On Wed, Mar 30, 2016 at 8:03 AM, Ryan Utz <utz.r...@gmail.com> wrote: >> >>> Hello, >>> >>> I have a time series that represents data sampled every 15-minutes. The >>> data currently run from November through February, 8623 total readings. >>> There are definitely daily periodic trends and non-stationary long-term >>> trends. I would love to decompose this using basic time series analysis. >>> >>> However, every time I attempt decomposition, I get the >>> >>> Error in decompose( ) : time series has no or less than 2 periods >>> >>> Is it only possible to do basic time-series analysis if you have a year >>> or >>> more worth of data? That seems absurd to me, since there is definite >>> periodicity and the data are a time series. I have tried every manner of >>> specifying frequency= with no luck (96 does not work). All manner of >>> searching for help has turned up fruitless. >>> >>> Can I only do this after I wait another year or two? >>> >>> Thanks, >>> Ryan >>> >>> -- >>> >>> Ryan Utz, Ph.D. >>> Assistant professor of water resources >>> *chatham**UNIVERSITY* >>> Home/Cell: (724) 272-7769 >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> 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. >>> >> >> > > > -- > > Ryan Utz, Ph.D. > Assistant professor of water resources > *chatham**UNIVERSITY* > Home/Cell: (724) 272-7769 > > [[alternative HTML version deleted]] ______________________________________________ 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.