且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 ts() 对象对每周数据进行 R 时间序列建模

更新时间:2023-02-26 15:58:41

使用非整数频率效果很好,并且与大多数模型(auto.arima、ets 等)兼容.对于开始日期,我只使用 lubridate 中的便利功能.在处理可能不同的开始和结束日期的多个时间序列时,这里的重要性是保持一致.

Using non-integer frequencies works quite well and is compatible with most models (auto.arima, ets, ...). For the start date, I just use the convenience functions in lubridate. The importance here is to be consistent when working with multiple time series of potentially different start and end dates.

library(lubridate)
ts(df$Amount, 
   freq=365.25/7, 
   start=decimal_date(ymd("2006-12-27")))