简体   繁体   English

时间序列模型,R中包含每日数据

[英]Time Series Model with daily data in R

I have a dataset with 2 years of daily data. 我有一个包含2年每日数据的数据集。 The type of data has two seasonal components (weekly and monthly ie each type of day behaves in similar way and the same for each month). 数据类型有两个季节性组件(每周和每月组成,即每种类型的一天表现方式相似,每个月相同)。 Lets forget holidays fall in different dates each year. 让我们忘记每年不同日期的假期。 I need to build a time series model to forecast 1 or two months of daily data. 我需要建立一个时间序列模型来预测1或2个月的每日数据。 I've tried ARIMA with different parameters and the predictor always flattens out. 我尝试过不同参数的ARIMA,预测器总是变平。

Here my code: 这是我的代码:

df <read.csv("data.csv", header = TRUE, sep = ";")
tseries <-ts(df[,2],start=1,frequency=7) -- also tried msts but not working        
ARIMAfit <- auto.arima(log10(tseries), approximation=FALSE,trace=FALSE)
Series: log10(tseries) 
ARIMA(2,0,1)(2,0,0)[7] with non-zero mean 

Coefficients:
      ar1     ar2     ma1    sar1    sar2  intercept
  -0.1203  0.2423  0.6590  0.3182  0.4490     2.0577
    s.e.   0.1495  0.0900  0.1404  0.0330  0.0335     0.0508

 sigma^2 estimated as 0.03187:  log likelihood=222.5
AIC=-430.99   AICc=-430.84   BIC=-398.82

Training set error measures:
                  ME      RMSE       MAE        MPE     MAPE      MASE
Training set 0.000745645 0.1777786 0.1273053 -0.7742803 6.340793 0.8641706
                ACF1
Training set -0.00434844

pred <- predict(ARIMAfit, n.ahead = 500)

lines(10^(pred$pred),col="yellow")

在此输入图像描述

I'm not an expert on this kind of modelling so probably I'm making a basic mistake. 我不是这种建模的专家,所以我可能犯了一个基本的错误。 Any help on this will be much appreciated. 任何有关这方面的帮助将非常感激。

BR BR

Tomás 托马斯

1)See this discussion . 1)见这个讨论 on using dummy variables to estimate the monthly and day of the week impacts along with searching for outliers, changes in level, time trends, and changes in day of the week effects (ie seasonal pulses) 2)Why are you logging your data? 使用虚拟变量来估算每周和每周的影响以及搜索异常值,水平变化,时间趋势以及星期几效应的变化(即季节性脉冲)2)为什么要记录您的数据? See this discussion . 见这个讨论
3)Post your data with the date and the country where your data is from. 3)将数据发布到数据所在的日期和国家/地区。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM