R quantmod buildModel()不适合模型

时间:2017-02-11 19:48:04

标签: r runtime-error quantmod

在使用buildModel拟合模型时,我无法解决错误,tradeModel似乎不起作用,因此使用getSymbols('GS',src='yahoo') q.model = specifyModel(Next(OpCl(GS)) ~ Lag(OpHi(GS),0:3)) buildModel(q.model, method='lm',training.per=c('2007-08-01','2007-09-30')) > q.model # it seems that model is still 'None fitted' ? quantmod object: Build date: Model Specified: Next(OpCl(GS)) ~ Lag(OpHi(GS), 0:3) Model Target: Next.OpCl.GS Product: GS Model Inputs: Fitted Model: None Fitted tradeModel(q.model,plot.model=TRUE,trade.dates=c("2008-01-01","2008-12-31")) Error in UseMethod("predict") : no applicable method for 'predict' applied to an object of class "NULL" 上升错误:

---------- Stored Procedure Start--------

DECLARE   name varchar2(10);
PROCEDURE printVal (name varchar2) IS
BEGIN
   dbms_output.put_line ('name:' || name);
END;  
--------- Stored Procedure End-----------

----------anonymous block Start----------
BEGIN
  name := 'Joe';
  printVal(name);
END;
/
----------anonymous block end ------------

1 个答案:

答案 0 :(得分:4)

好的,这是一个“卑鄙”的文档。似乎getSymbols()函数接管赋值给变量而不是buildModel(),即使?buildModel中的示例可能表明这一点。 简而言之:您需要将buildModel()的结果分配给变量,例如q.model。我希望你能笑出来;)

library(quantmod)
getSymbols('GS',src='yahoo')
q.model <- specifyModel(Next(OpCl(GS)) ~ Lag(OpHi(GS),0:3))
q.model <- buildModel(q.model, method='lm',training.per=c('2007-08-01','2007-09-30'))
q.model