我目前正在 R 中使用 ergm.count 包来建模有价值的定向网络。邻接矩阵可以通过这个link下载。该网络由 84 个节点和 75 个加权关系组成。
library(ergm.count)
mat <- as.matrix(read.csv("./mat.csv",header=TRUE)[,-1])
net<-as.network(mat , directed=TRUE, matrix.type="a",
ignore.eval=FALSE, names.eval="cnts"
)
m1<-ergm(net~ transitiveweights("min", "max", "min"),
reference=~Poisson,
response="cnts",
control=control.ergm(parallel=6, parallel.type="PSOCK",
main.method="MCMLE")
)
但是,当我运行上面的代码时,进度感觉像是永远卡住了,而且cpu负载非常高。
我不知道发生了什么以及我的代码有什么问题。有什么方法可以加快或优化进度。顺便说一句,我的 R 版本是 4.3.2,ergm 版本是 4.5.0,这是拟合输出...
Starting contrastive divergence estimation via CD-MCMLE:
Iteration 1 of at most 60:
Convergence test P-value:1.5e-04
The log-likelihood improved by 0.07426.
Iteration 2 of at most 60:
Convergence test P-value:6.2e-03
The log-likelihood improved by 0.03396.
Iteration 3 of at most 60:
Convergence test P-value:5.9e-01
Convergence detected. Stopping.
The log-likelihood improved by 0.001075.
Finished CD.
Starting Monte Carlo maximum likelihood estimation (MCMLE):
Iteration 1 of at most 60:
编辑:
等待三个小时并打印日志后,进程停止并显示:
> source("/root/transfer_analysis/test.R", encoding = "UTF-8")
Evaluating network in model.
Initializing unconstrained Metropolis-Hastings proposal: ‘ergm.count:MH_DiscTNT’.
Initializing model...
Model initialized.
Using initial method 'CD'.
Fitting initial model.
Starting contrastive divergence estimation via CD-MCMLE:
Iteration 1 of at most 60:
Convergence test P-value:1.5e-06
The log-likelihood improved by 0.1578.
Iteration 2 of at most 60:
Convergence test P-value:2.6e-02
The log-likelihood improved by 0.02119.
Iteration 3 of at most 60:
Convergence test P-value:4.6e-01
The log-likelihood improved by 0.002026.
Iteration 4 of at most 60:
Convergence test P-value:1e-01
The log-likelihood improved by 0.01116.
Iteration 5 of at most 60:
Convergence test P-value:1.4e-01
The log-likelihood improved by 0.007586.
Iteration 6 of at most 60:
Convergence test P-value:1e+00
Convergence detected. Stopping.
The log-likelihood improved by < 0.0001.
Finished CD.
Starting Monte Carlo maximum likelihood estimation (MCMLE):
Density guard set to 10000 from an initial count of 75 edges.
Iteration 1 of at most 60 with parameter:
transitiveweights.min.max.min
-1.483437
Starting unconstrained MCMC...
Back from unconstrained MCMC.
Error in ergm.MCMLE(init, s, s.obs, control = control, verbose = verbose, :
Unconstrained MCMC sampling did not mix at all. Optimization cannot continue.
Additional warning message:
In ergm_MCMC_sample(s, control, theta = mcmc.init, verbose = max(verbose - :
Unable to reach target effective size in iterations alotted.
我已经检查了另一个关于“无法在分配的迭代中达到目标有效大小”的问题,但是这个拟合模型和公式似乎非常简单
任何帮助将不胜感激!
我怀疑由于模型规范,估计会陷入困境。我建议您在拟合复杂模型(例如带有
transitiveweights
的模型)之前先探索数据。我不知道您要建模的系统是什么,所以显然下面的内容与物质无关:
sum
)。这些是否适合数据,如果不适合,如何?transitiveweights
的模型也应该具有 sum
。