2

我有一个 xts 对象close(带有POSIXct索引)。当我运行quantmod命令时,它给出了这个错误specifyModel(close[,1] ~ close[,2])

 Error in UseMethod("as.xts") : 
  no applicable method for 'as.xts' applied to an object of class "function".

                     ALBK ANDHRABANK AXISBANK BANKBARODA
2007-01-02 10:01:00 90.89      87.33   468.55     243.95
2007-01-02 10:02:00 90.80      86.92   467.75     243.70
2007-01-02 10:03:00 90.45      86.77   468.65     243.60
2007-01-02 10:04:00 90.31      86.94   468.32     243.95
2007-01-02 10:05:00 90.27      87.05   468.60     244.00
2007-01-02 10:06:00 90.23      87.00   468.00     243.65
2007-01-02 10:07:00 90.24      86.89   467.50     243.60
2007-01-02 10:08:00 89.99      86.77   467.05     243.00
2007-01-02 10:09:00 90.05      86.80   467.40     243.00
2007-01-02 10:10:00 90.20      87.00   467.00     243.00

这个错误是什么意思,我该如何解决?

4

1 回答 1

2

它变得混乱,因为它close是基本 R 函数的名称。(可能是一个错误,但我不确定它的使用specifyModel范围有多广)

> close <- getSymbols("SPY", src="yahoo", auto.assign=FALSE)
> specifyModel(close[, 1] ~ close[, 2])
Error in UseMethod("as.xts") : 
  no applicable method for 'as.xts' applied to an object of class "function"

通过重命名 xts 对象来修复

> dat <- close
> specifyModel(dat[, 1] ~ dat[, 2])

quantmod object:        Build date:   

Model Specified: 
     dat[, 1] ~ dat[, 2] 

Model Target:  [ dat 0.1         Product:  dat 
Model Inputs:   

Fitted Model: 

    None Fitted
> 
于 2013-01-18T17:49:31.497 回答