Yanita Yanita - 2 months ago 8
Python Question

Cannot use fracdiff.sim and arfima.sim from python - 'DocumentedSTFunction' object has no attribute 'sim'

I want to use R packages

fracdiff
and
arfima
from python. I imported this libraries with
rpy2
as

from rpy2.robjects.packages import importr
fracdiff = importr('fracdiff')
arfima = importr('arfima')


But when I try to execute

fracdiff.fracdiff.sim()


or

arfima.arfima.sim()


I received error


AttributeError: 'DocumentedSTFunction' object has no attribute 'sim'


Both of them are executed in R console. In python only
fracdiff.fracdiff()
and
arfima.arfima()
are executed. What can be wrong? Thanks for help.

Answer

Dots (.) are not valid names for Python variables.

For that reason, importr is trying to convert . into _.

Try fracdiff.fracdiff_sim().