rpy2,copula,如何导入参数? Python
rpy2, copula, How to import parameters? Python
我要翻译:
library(copula)
myCop.clayton <- archmCopula(family="clayton", dim =7, param=2)
myMvd <- mvdc(copula=myCop.clayton, margins=c("norm", "norm"),
paramMargins = list(list(mean=0.66,sd = 0.1),
list(mean=0.66,sd = 0.1)))
使用 rpy2
进入 Python
`myMvd = copula.mvdc(copula=myCop, margins=robjects.StrVector(["norm", "norm"]),
paramMargins = robjects.vectors.ListVector(
[robjects.vectors.FloatVector([0.66, 0.1]),
robjects.vectors.FloatVector([0.66, 0.1])]))`
但不幸的是,在 RStudio 和 Python 解释器中生成的图非常不同。我该如何翻译:
paramMargins = list(list(mean=0.66,sd = 0.1), list(mean=0.66,sd = 0.1))
进入Python?
此致
拉法尔
R代码
图书馆(copula)
myCop_clayton <- archmCopula(family="clayton", dim =7, param=2)
myMvd <- mvdc(copula=myCop_clayton, margins=c("norm", "norm"),
paramMargins = list(list(mean=0.66,sd = 0.1),
列表(均值=0.66,sd = 0.1)))
可以简单地翻译成 rpy2,通过使用 R 代码片段,其中翻译对您来说似乎很复杂。例如:
from rpy2.robjects.packages import importr
copula = importr('copula')
myCop_clayton = copula.archmCopula(family="clayton", dim =7, param=2)
from rpy2.robjects.vectors import StrVector, ListVector
from rpy2.robjects import r
myMvd = copula.mvdc(copula=myCop,
margins=StrVector(["norm", "norm"]),
paramMargins = r("""
list(list(mean=0.66,sd = 0.1),
list(mean=0.66,sd = 0.1))
"""))
否则paramMargins
可以表示为:
ListVector([("V1", ListVector([{"mean": 0.66, "sd": 0.1}])),
("V2", ListVector([{"mean": 0.66, "sd": 0.1}]))])
我要翻译:
library(copula)
myCop.clayton <- archmCopula(family="clayton", dim =7, param=2)
myMvd <- mvdc(copula=myCop.clayton, margins=c("norm", "norm"),
paramMargins = list(list(mean=0.66,sd = 0.1),
list(mean=0.66,sd = 0.1)))
使用 rpy2
进入 Python`myMvd = copula.mvdc(copula=myCop, margins=robjects.StrVector(["norm", "norm"]),
paramMargins = robjects.vectors.ListVector(
[robjects.vectors.FloatVector([0.66, 0.1]),
robjects.vectors.FloatVector([0.66, 0.1])]))`
但不幸的是,在 RStudio 和 Python 解释器中生成的图非常不同。我该如何翻译:
paramMargins = list(list(mean=0.66,sd = 0.1), list(mean=0.66,sd = 0.1))
进入Python?
此致 拉法尔
R代码 图书馆(copula) myCop_clayton <- archmCopula(family="clayton", dim =7, param=2) myMvd <- mvdc(copula=myCop_clayton, margins=c("norm", "norm"), paramMargins = list(list(mean=0.66,sd = 0.1), 列表(均值=0.66,sd = 0.1)))
可以简单地翻译成 rpy2,通过使用 R 代码片段,其中翻译对您来说似乎很复杂。例如:
from rpy2.robjects.packages import importr
copula = importr('copula')
myCop_clayton = copula.archmCopula(family="clayton", dim =7, param=2)
from rpy2.robjects.vectors import StrVector, ListVector
from rpy2.robjects import r
myMvd = copula.mvdc(copula=myCop,
margins=StrVector(["norm", "norm"]),
paramMargins = r("""
list(list(mean=0.66,sd = 0.1),
list(mean=0.66,sd = 0.1))
"""))
否则paramMargins
可以表示为:
ListVector([("V1", ListVector([{"mean": 0.66, "sd": 0.1}])),
("V2", ListVector([{"mean": 0.66, "sd": 0.1}]))])