首页 > 解决方案 > Python中的R。错误:$ 运算符对原子向量无效

问题描述

我刚开始尝试在 Python 中使用 R,因为有一些有趣的包。我正在使用包 rpy2 在 python 环境中使用 R。有人可以帮我理解为什么我有这个错误吗?我不在我的代码中使用 $ 。错误发生在 fitMCMC。

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


spec = ms.CreateSpec(variance_spec = ro.ListVector( ro.StrVector(['sGARCH', 'sGARCH'])),
              distribution_spec = ro.ListVector( ro.StrVector(['norm', 'norm']))
              )

X = my_data
fitMCMC = ms.FitMCMC(spec = spec, data = X, ctr = ro.ListVector({'nburn' : '500L', 'nmcmc' : '500L', 'nthin' : '1L'}))
print(base.summary(fitMCMC))

标签: pythonrrpy2

解决方案


推荐阅读