使用 ergm 时 R 会破裂

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

我有一个很大的网络,当我运行 ergm 模型时,R 总是会崩溃。 (同时它显示内存使用率很高)。

有人知道我能做什么吗?

library(network)
library(ergm)
gc()

model.1a <- ergm(net[[1]] ~ edges() + 
    nodecov("dist2coast") + nodecov("dist2rail60") + 
    nodecov("dist2paved") + edgecov(dist_matrix),
  control = control.ergm(
    seed        = 1,
    MCMLE.maxit = 10,
    parallel    = 4,
    CD.maxit    = 10
  )
) 

net[[1]]
 Network attributes:
  vertices = 7819 
  directed = FALSE 
  hyper = FALSE 
  loops = FALSE 
  multiple = FALSE 
  bipartite = FALSE 
  total edges= 273 
    missing edges= 0 
    non-missing edges= 273 

 Vertex attribute names: 
    agglosID agglosName builtUp capital class1 class2 class3 dist2capital dist2coast dist2emst dist2first dist2impr dist2paved dist2placebo16 dist2placebo22 dist2rail60 dist2rail60mil dist2rail60min dist2river dist2second first geometry ISO3 L1 Latitude Longitude mean2010 Metropole nodeID.1 notown Pop1950 Pop1960 Pop1970 Pop1980 Pop1990 Pop2000 Pop2010 Pop2015 prec_mean second sparseveg undetermined vertex.names Voronoi water 

No edge attributes
r statnet ergm
1个回答
0
投票

这里有几个问题:

  1. 在模型公式中写
    edges
    ,不带括号。
  2. 您的网络极其稀疏——7819 个节点中有 273 条边。网络密度约为 10^(-4)。你确定这是正确的吗?
  3. 我们已经使用了具有 10 万个节点的网络,但您需要 RAM。您的电脑有足够的内存吗?
  4. 您正在拟合一个二元独立模型。这样的模型简化为 logit GLM,但适合相当大的模型矩阵,特别是您有一个
    edgecov
    项,其矩阵为 7819 x 7819。不过,MCMC 并未使用,因此 (1) 您不需要 MCMC 和CD 控制参数和 (2) 您所经历的“R 的破坏”并不是由于马尔可夫链误入歧途。
  5. 尝试使用
    verbose=TRUE
    ergm()
    重新运行估计,并使用它生成的消息更新您的问题。否则很难推断出估计发生了什么。
© www.soinside.com 2019 - 2024. All rights reserved.