错误:模块“MSGARCH”没有属性“predict”

2024-03-29 12:16:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用包rpy2在Python环境中使用R语言。我使用的是MSGARCH包,它只在R上。这个包显然应该带有predict属性。 https://rdrr.io/cran/MSGARCH/man/predict.html 我不明白为什么我会有这个错误。你有什么想法吗?你知道吗

完整的错误消息是:

Traceback (most recent call last):
  File "markov.py", line 165, in <module>
    pred = ms.predict(object = fitMCMC, newdata = None, nahead = '30L')
AttributeError: module 'MSGARCH' has no attribute 'predict'

代码是:

ms = importr('MSGARCH')
from rpy2.robjects import r, pandas2ri, numpy2ri, vectors
pandas2ri.activate()
numpy2ri.activate()
base = importr('base')
stats = importr('stats')

pred = ms.predict(object = fitMCMC, newdata = None, nahead = '30L')

Tags: noneobject错误predictmsmodulerpy2pred