【问题标题】:Error in round(frequency): non-numeric argument to math function from VAR model回合误差(频率):来自 VAR 模型的数学函数的非数字参数
【发布时间】:2017-06-01 16:06:04
【问题描述】:

帮助解决:

fcst.tmp 回合错误(频率):数学函数的非数字参数

来自代码:

library(vars)  
tmp.matrix <- matrix(data = c(0,                     -0.0018674142,                     0.0046620131,
                     0.0037140247,                     -0.0009272138,                     0.0064725145,
                     -0.000922084,                     -0.0046232167,                     0.0210920245,
                     -0.0100320039,                     0.0136551962,                     -0.00725956,
                     0.0251811866,                     -0.0089206658,                     -0.000896459,
                     0.0035810244,                     0.0159577854,                     -0.0097216851,
                     0.0176060886,                     0.0034843241,                     -0.0017406445,
                     0.0198367867,                     -0.0034217313,                     -0.0225312824,
                     -0.0043917506,                     0.0157208478,                     -0.0148409533,
                     0.0234691345,                     -0.0401374128,                     -0.0132217389,
                     0.0269124178,                     -0.006590583,                     0.0255472708,
                     0.003401652,                     0.0052493174,                     -0.0011235182,
                     -0.0033622663,                     -0.0193530068,                     -0.0302611445,
                     -0.0076587663,                     -0.0023782155,                     -0.026358019,
                     0.0161200327,                     0.0171822796,                     0.0193783756,
                     0.0091528136,                     -0.0101419116,                     -0.0013561094,
                     0.000172569,                     -0.0071663343,                     -0.0119922952,
                     0.0044839696,                     0.0029657989,                     -0.0114150402,
                     -0.0018366463,                     0.0116721141),ncol = 2)

colnames(tmp.matrix) <- c("Col1","Col2")

VAR.tmp <- VAR(tmp.matrix, p=1, type = "const")

fcst.tmp <- forecast(VAR.tmp)

附言

tmp.matrix 需要转换为时间序列:

ts.matrix <- as.ts(tmp.matrix)
VAR.tmp <- VAR(ts.matrix, p=1, type = "const")
fcst.tmp <- forecast(VAR.tmp)
plot(fcst.tmp)

【问题讨论】:

  • 最后,您的错误无法重现。我尝试了forecast 函数以确保得到VAR.tmp 的良好情节。

标签: r rounding frequency var


【解决方案1】:

tmp.matrix 需要通过以下方式转换为时间序列:

ts.matrix <- as.ts(tmp.matrix)

VAR.tmp <- VAR(ts.matrix, p=1, type = "const")

fcst.tmp <- forecast(VAR.tmp)

plot(fcst.tmp)

【讨论】:

    【解决方案2】:

    我有同样的问题。如果您使用 predict() 而不是 forecast(),则可以解决此问题。

    ts.matrix <- as.ts(tmp.matrix)
    
    VAR.tmp <- VAR(ts.matrix, p=1, type = "const")
    
    fcst.tmp <- predict(VAR.tmp)
    
    plot(fcst.tmp)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多