简体   繁体   English

无法在R中进行每日时间序列分析

[英]Not able to make daily time series analysis in R

The following is my data, 以下是我的数据,

 day       sum
2015-03-05   44           
2015-03-06   46           
2015-03-06   48           
2015-03-07   48           
2015-03-08   58           
2015-03-09   58           
2015-03-10   66           
2015-03-11   68           
2015-03-12   85           
2015-03-13   94           
2015-03-14   98           
2015-03-15  102           
2015-03-16  102           
2015-03-17  104           
2015-03-17  114 

The type of variables used are as follows, 使用的变量类型如下:

typeof(x)
[1] "list"

typeof(x$day)
[1] "double"

typeof(x$sum)
[1] "integer"

class(x$day)
[1] "Date"

I want to predict, for a particular future date, what would be the sum. 我想预测在将来的特定日期将是多少。

The following are my findings, 以下是我的发现,

When I use ts(x), the values of the dates are changing as follows, 当我使用ts(x)时,日期值的变化如下,

day

16464              

16465              

16466

16467

16468

16469

16470

16471

16472

When I use ets, following is the output, 当我使用ets时,输出如下,

fit <- ets(x)
Error in ets(ana) : y should be a univariate time series

I am able to plot the dates with the sum and getting the graphs perfectly. 我能够用总和来绘制日期并完美地得到图形。 But, I am not able to make any analysis after this point. 但是,在此之后,我无法进行任何分析。 I want to predict, for a particular future date, what would be the sum. 我想预测在将来的特定日期将是多少。 I tried regression analysis also, but it doesn't work with this variable. 我也尝试了回归分析,但不适用于此变量。 Can anybody please help me how to proceed further? 有人可以帮我进一步进行吗?

Thanks 谢谢

If you "correct" the duplicated days, you will be able to do this: 如果您“纠正”重复的日期,则可以执行以下操作:

library(xts)
dates=as.Date(x$day,"%Y-%m-%d")
xs=xts(x$sum,dates)
plot(xs)
library("forecast")
class(xs)
fit <- ets(xs)
plot(forecast(fit))

在此处输入图片说明

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

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