0
我一直使用从forecast
包nnetar
功能时,得到了以下错误:错误使用前馈神经网络时,从“预测”包
Error in rowMeans(sapply(fit, predict)) : 'x' must be an array of at least two dimensions Called from: rowMeans(sapply(fit, predict))
但没有错误,当我采取相同的输入数据并逐行运行nnetar
函数(我可以做它,因为它的源可用)。你能帮我理解错误背后的原因吗?
代码重现错误:
library("forecast")
x <- structure(c(75.4076478, 74.77923336, 74.27204018, 73.47822515,
73.29823134, 72.91366804, 73.26790178, 74.09299464, 74.95585689,
75.43382793, 77.15040162, 78.22886226, 78.30629811, 78.79626749,
78.58930659, 77.3918156, 76.9386785, 76.39462267, 75.96094635,
75.20484764, 73.75982041, 73.37559835, 73.28544776, 72.63796541
), .Tsp = c(1, 1.95833333333333, 24), class = "ts")
nnetar(x, p = 6)
会议信息:
R version 3.3.0 (2016-05-03) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1 locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] forecast_8.0 loaded via a namespace (and not attached): [1] Rcpp_0.12.9 quadprog_1.5-5 lattice_0.20-33 zoo_1.7-14 lmtest_0.9-35 [6] assertthat_0.1 grid_3.3.0 plyr_1.8.4 gtable_0.2.0 magrittr_1.5 [11] scales_0.4.1 ggplot2_2.2.1 lazyeval_0.2.0 tseries_0.10-40 fracdiff_1.4-2 [16] timeDate_3012.100 tools_3.3.0 munsell_0.4.3 parallel_3.3.0 colorspace_1.3-2 [21] nnet_7.3-12 tibble_1.2
这适用于我:nnetar(as.numeric(x),p = 6) – Stergios
这也适用于我,谢谢。当输入是'ts'对象时,为什么它不起作用仍然不清楚。 –