首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >R中的并行处理:基本错误(Val):7个节点产生错误;第一个错误:未使用的参数(checkForRemoteErrors= base::quote(2))

R中的并行处理:基本错误(Val):7个节点产生错误;第一个错误:未使用的参数(checkForRemoteErrors= base::quote(2))
EN

Stack Overflow用户
提问于 2020-09-27 17:08:05
回答 1查看 468关注 0票数 0

我正在尝试使用apply系列函数进行并行计算,代码如下。目标是使silum_矩阵的每一列都适合我的规范,当我检查

代码语言:javascript
运行
复制
dim((simul_[,1]))

我得到"NULL“,这会导致应用函数出现问题。完整的代码如下:

代码语言:javascript
运行
复制
## Library
lib_vec = c("MSGARCH", "matrixStats", "parallel")
invisible(lapply(lib_vec, f_install_load_lib)) 

## seed
set.seed(1234)

MSGARCH包中的MSGARCH模型规范

代码语言:javascript
运行
复制
MSGARCH_spec <- CreateSpec(variance.spec = list(model = c("sGARCH", "sGARCH")),
                            distribution.spec = list(distribution = c("norm",
                                                                      "norm")),
                            switch.spec = list(do.mix = FALSE, K = NULL),
                            constraint.spec = list(fixed = list(), 
                                                   regime.const = NULL),
                            prior = list(mean = list(), sd = list()))

MSGARCH拟合: sp500_logrets只是对数返回。

代码语言:javascript
运行
复制
MSgarch_fit <- FitML(data = sp500_logrets, spec = MSGARCH_spec)

模拟MSGARCH Log_returns

代码语言:javascript
运行
复制
nsim <- 100 # number of simulations
nahead <- 1000 # size of each simualtion
MS_simul <- simulate(MSgarch_fit, nsim = nsim, nahead = nahead, n.start = 500, 
                     nburn = 100)
simul_ <- MS_simul$draw # retrieving the simulated data

并行计算设置

代码语言:javascript
运行
复制
n_cores <- detectCores()
cl <- makeCluster(n_cores[1] - 1)

通过并行计算将每个模拟与应用函数进行拟合

代码语言:javascript
运行
复制
fitt_ <- parSapply(cl, X = simul_, MARGIN = 2, FUN = FitML, spec = MSGARCH_spec)

stopCluster(cl)

我得到的错误是:

代码语言:javascript
运行
复制
7 nodes produced errors; first error: unused argument (MARGIN = base::quote(2))

我想我很迷茫,非常感谢任何人的帮助:)

EN

回答 1

Stack Overflow用户

发布于 2020-09-27 18:58:21

错误非常明显:

代码语言:javascript
运行
复制
7 nodes produced errors; first error: unused argument (MARGIN = base::quote(2))

parSapply() / sapply()中没有参数MARGIN。你可能把apply()搞错了。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64086736

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档