【发布时间】:2019-02-17 19:37:40
【问题描述】:
在使用 R 对时间序列进行指数平滑时,我以 Average Yearly Temperatures in New Haven 为例。
代码使用 1912 年到 1960 年作为训练数据,并生成未来 11 年的预测。
我想将预测与 1961 年到 1971 年的实际情况进行比较,但有两个问题:
- 获取实际值的“nht_1”返回一些错误的数字
-
尝试获取 RMSE 时弹出错误:
order(y) 中的错误:“orderVector1”中未实现类型“list”
如何纠正它们并获得预测值的 RMSE?谢谢。
(注意:除了使用预测包中的准确度命令。我想尝试以这种方式获取 RMSE...)
df <- read.csv("D:\\Documents\\nhtemp.csv")
nht <- ts(df$value,
start = c(1912),
end = c(1960),
frequency = 1)
nht.hw1 <- HoltWinters(df$value, gamma = F); nht.hw1
library(forecast)
nht.forecast <- forecast(nht.hw1, h = 11)
nht.forecast
# I want to compare the forecast with the actual of year 1961 to 1971:
nht_1 <- ts(df$value,
start = c(1961),
end = c(1971),
frequency = 1)
nht_1
# returns wrong numbers: 49.9 52.3 49.4 51.1 49.4 47.9 49.8 50.9 49.3 51.9 50.8
# For getting its RMSE
library(caret)
postResample(nht_1, nht.forecast)
# Error in order(y) : unimplemented type 'list' in 'orderVector1'
【问题讨论】:
标签: r time-series