简体   繁体   中英

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,

day

16464              

16465              

16466

16467

16468

16469

16470

16471

16472

When I use ets, following is the output,

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))

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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