【问题标题】:Error in eval(expr, envir, enclos): could not find function "qGumbel"eval 中的错误(expr、envir、enclos):找不到函数“qGumbel”
【发布时间】:2025-04-21 16:50:02
【问题描述】:

我对 R 比较陌生,并试图模拟 Gumbel copula,其中一个边距是 gumbel pdf,另一个是指数型。

通过此代码

G3 <- gumbelCopula(1.37, dim=2)
gMvd2 <- mvdc(G3, c("Gumbel","exp"), param = list(list(shape=10.2988298881251, scale=1.02463492397923), list(rate=4)))
set.seed(11)
# n <- if(Xtras) 10000 else 200 # sample size (realistic vs short for example)
x <- rMvdc(100, gMvd2)
head(x)

输出是:

Error in eval(expr, envir, enclos): could not find function "qGumbel"
Traceback:

1. rMvdc(100, gMvd2)
2. eval(qdf.expr, list(x = u[, i]))
3. eval(expr, envir, enclos)

他们也提到了备注

mvdCheckM(margins, "p") 中的警告信息:

"margins correct? Currently, have no function(s) named: pGumbel"Warning message in mvdCheckM(margins, "d"):
"margins correct? Currently, have no function(s) named: dGumbel"

我认为问题在于边际分布的参数值,因为当我输入时

G3 <- gumbelCopula(1.37, dim=2)
gMvd2 <- mvdc(G3, c("exp","exp"), param = list(list(rate=2), list(rate=4)))
set.seed(11)
# n <- if(Xtras) 10000 else 200 # sample size (realistic vs short for example)
x <- rMvdc(100, gMvd2)
head(x)

没问题!!

【问题讨论】:

标签: r statistics simulation


【解决方案1】:

正如 Elin 在评论中提到的那样,我通过将大写 G 更改为小 g 并添加了我自己的功能来做到这一点

qgumbel <- function(p,shape,scale) shape-scale *log(-log(p))

现在代码可以工作了

G3 <- gumbelCopula(1.37, dim=2)
gMvd2 <- mvdc(G3, c("gumbel","exp"), param = list(list(shape=10.2988298881251, scale=1.02463492397923), list(rate=4)))
set.seed(11)
# n <- if(Xtras) 10000 else 200 # sample size (realistic vs short for example)
x <- rMvdc(100, gMvd2)
head(x)
#  parameter values of the marginal distributions 

【讨论】: