[英]Not able to make daily time series analysis in R
以下是我的數據,
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
使用的變量類型如下:
typeof(x)
[1] "list"
typeof(x$day)
[1] "double"
typeof(x$sum)
[1] "integer"
class(x$day)
[1] "Date"
我想預測在將來的特定日期將是多少。
以下是我的發現,
當我使用ts(x)時,日期值的變化如下,
day
16464
16465
16466
16467
16468
16469
16470
16471
16472
當我使用ets時,輸出如下,
fit <- ets(x)
Error in ets(ana) : y should be a univariate time series
我能夠用總和來繪制日期並完美地得到圖形。 但是,在此之后,我無法進行任何分析。 我想預測在將來的特定日期將是多少。 我也嘗試了回歸分析,但不適用於此變量。 有人可以幫我進一步進行嗎?
謝謝
如果您“糾正”重復的日期,則可以執行以下操作:
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.