statnet / ergm.multi

Fit, Simulate and Diagnose Exponential-Family Models for Multiple or Multilayer Networks
Other
14 stars 1 forks source link

Stochastic error in multilayer.R test (numerical precision?) #11

Closed krivit closed 2 years ago

krivit commented 2 years ago
library(ergm.multi)
set.seed(70)
nw0 <- network.initialize(10, dir=FALSE)
(nw1 <- simulate(nw0~edges, coef=-.5))
(nw2 <- simulate(nw0~edges, coef=+.5))
(layer <- coef(ergm(Layer(nw1, nw2) ~ L(~edges, ~`1`) + L(~edges, ~`2`))))
#> L(1)~edges L(2)~edges 
#> 0.04445176 0.22314355
(logic <- c(coef(ergm(nw1~edges)), coef(ergm(nw2~edges))))
#>      edges      edges 
#> 0.04445176 0.22314355
stopifnot(isTRUE(all.equal(layer, logic, check.attributes=FALSE)))
#> Error: isTRUE(all.equal(layer, logic, check.attributes = FALSE)) is not TRUE

Created on 2022-07-03 by the reprex package (v2.0.1)