ERGM MCMC 诊断联合图

问题描述 投票:0回答:1

如何将两个(或多个)ERGM 估计的 MCMC 诊断图合并到一张图中,如下例所示?

library(ergm)
library(latticeExtra)

data(florentine)

# Fit two ERGM models
model1 <- ergm(flomarriage ~ edges + kstar(2))
model2 <- ergm(flomarriage ~ edges + kstar(2) + triangle)

mcmc.diagnostic(model1)
mcmc.diagnostic(model2)

enter image description here

r plot ergm
1个回答
0
投票

您需要使用coda(无论如何都依赖于ergm)和一些lattice体操,例如:

p1 <- model1$sample |>
  coda::as.mcmc.list() |>
  ergm_plot.mcmc.list(main = "Model 1")

p2 <- model2$sample |>
  coda::as.mcmc.list() |>
  ergm_plot.mcmc.list(main = "Model 2")

plot(p1, split=c(1,1,2,1) )
plot(p2, split=c(2,1,2,1), newpage = FALSE)

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.