我目前无法显示数据。将尽快提交样本数据。
下面是我用来遍历每个变量并保存点估计值的代码。
##nnetar loop####
fits <- lapply(1:ncol(tser), function(i) nnetar(tser[,i], P=2, repeats=750, scale.inputs = T))
models <- sapply(1:ncol(tser), function(i) forecast(fits[[i]])$method)
results <- lapply(1:ncol(tser), function(i) forecast(fits[[i]], h = 12))
#Saves out Point Forecasts#
resultsmean <- lapply(1:ncol(tser), function(i) forecast(fits[[i]], h = 12)$mean)
跑步&#34;适合&#34;对象行,我收到错误:
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases
dput()语句,用于重现我转换为ts()对象的数据集&#34; tser&#34;:
sampledata&lt; - structure(list(X1 = c(0,0,0,0,0,0,0,40,157,204,166, 237,211,161,216,291,222,234,243,185,163,150,114,243, 96,15,6,5,19,10,4,7,2),X2 = c(0,0,0,0,0,0,41, 53,70,45,78,60,36,53,63,91,123,101,50,69,41,32, 102,178,541,382,417,438,589,477,387,291),X3 = c(0, 0,0,0,0,0,0,1,1,13,28,34,27,33,42,38,70,57, 29,57,44,24,46,20,48,197,122,221,291,423,522,389 ),X4 = c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,3,31,34,36,37,40,83,78,84),X5 = c(521, 345,406,553,561,780,928,533,433,1121,631,439,406, 323,338,486,538,542,692,428,408,487,422,750,259,43, 97,95,23,35,28,15,26),X6 = c(0,0,0,0,0,0,00,7, 98,90,72,135,177,97,84,116,164,184,192,242,206,198, 127,293,292,776,622,503,762,764,602,614,528),X7 = c(0, 0,0,0,0,0,0,41,40,51,14,32,39,17,27,23,58,36, 46,22,42,33,37,45,348,1314,1150,842,1532,1386,1163, 1191,1011),X8 = c(0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,16,38,44,36,74,131,170,178, 247),X9 = c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,50,65),X10 = c(0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,4,6,0,4,2,2,0,6),X11 = c(0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 2,0,0,0,0),X12 = c(0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0()), X13 = c(1,5,58,68,127,177,275,280,238,475,221, 297,295,213,322,411,460,661,749,392,565,740,464, 624,211,31,23,13,5,8,9,4,1),X14 = c(0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 0,175,462,468,345,344,527,452,546,389)),. Name = c(&#34; X1&#34;, &#34; X2&#34;,&#34; X3&#34;,&#34; X4&#34;,&#34; X5&#34;,&#34; X6&#34;,&#34; X7& #34;,&#34; X8&#34;,&#34; X9&#34;,&#34; X10&#34;,&#34; X11&#34;, &#34; X12&#34;,&#34; X13&#34;,&#34; X14&#34;),class =&#34; data.frame&#34;,row.names = 72:104)< / p>