[R] ts or xts with high-frequency data within a year

Ryan Utz utz.ryan at gmail.com
Thu Mar 31 02:37:24 CEST 2016


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 <wdunlap at 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.ryan at 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 at 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]]



More information about the R-help mailing list