From 1548fb758b2b8619e2c7a9b89cadd2fd79788e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bojanowski?= Date: Mon, 10 Jun 2024 15:49:19 +0200 Subject: [PATCH 1/3] Comment two lines that trigger the error The `net.stats` object is never used. References statnet/ergm#561. --- R/ergm_mplecov.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/ergm_mplecov.R b/R/ergm_mplecov.R index 324e203da..4e1e9d3fd 100644 --- a/R/ergm_mplecov.R +++ b/R/ergm_mplecov.R @@ -83,8 +83,8 @@ ergm_mplecov <- function(pl, message("Estimating Godambe Matrix using ", R, " simulated networks.") # calculation of V(theta) = Var(u(theta,y)) using the sim.num networks - net.stat <- attr(sim.mple, "stats") - colnames(net.stat) <- colnames(pl$xmat) + # net.stat <- attr(sim.mple, "stats") + # colnames(net.stat) <- colnames(pl$xmat) u.data <- matrix(0,nrow=length(sim.mple), ncol=num.variables) for(i in 1:length(sim.mple)){ From 9da280e878b4cd33ba39b88a0dd30c66e6f52ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bojanowski?= Date: Mon, 10 Jun 2024 15:59:52 +0200 Subject: [PATCH 2/3] Add a test for Godambe cov of MPLE with offset References statnet/ergm#561. --- tests/testthat/test-mple-cov.R | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/testthat/test-mple-cov.R b/tests/testthat/test-mple-cov.R index a4a545a49..097e9ca7f 100644 --- a/tests/testthat/test-mple-cov.R +++ b/tests/testthat/test-mple-cov.R @@ -26,6 +26,18 @@ test_that("Godambe covariance method for MPLE", { expect_equal(StdErr1, c(0.255, 0.059), ignore_attr = TRUE, tolerance=.05) }) +test_that("Godambe covariance method for MPLE with offset", { + set.seed(111) + fit <- ergm( + init.sim ~ edges + triangles + offset(edges), + offset.coef = 0, + estimate = "MPLE", + control=control.ergm(MPLE.covariance.method = "Godambe") + ) + StdErr <- sqrt(diag(vcov(fit))) + expect_equal(StdErr, c(0.255, 0.059, 0), ignore_attr = TRUE, tolerance=.05) +}) + test_that("Inverse Hessian from logistic regression model", { set.seed(222) # However, this method is not stochastic m2 <- ergm(init.sim ~ edges+triangles, estimate = "MPLE", @@ -50,3 +62,5 @@ test_that("Bootstrap covariance method for MPLE with offsets", { StdErr4 <- sqrt(diag(vcov(m4))) expect_equal(StdErr4, c(0.155, 0.034, 0), ignore_attr = TRUE, tolerance=.05) }) + + From 49d372da8aa6cd16b1f3b3aa565b223a253136f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bojanowski?= Date: Tue, 11 Jun 2024 16:35:35 +0200 Subject: [PATCH 3/3] Removing the offending lines References statnet/ergm#561. --- R/ergm_mplecov.R | 2 -- 1 file changed, 2 deletions(-) diff --git a/R/ergm_mplecov.R b/R/ergm_mplecov.R index 4e1e9d3fd..c6e719602 100644 --- a/R/ergm_mplecov.R +++ b/R/ergm_mplecov.R @@ -83,8 +83,6 @@ ergm_mplecov <- function(pl, message("Estimating Godambe Matrix using ", R, " simulated networks.") # calculation of V(theta) = Var(u(theta,y)) using the sim.num networks - # net.stat <- attr(sim.mple, "stats") - # colnames(net.stat) <- colnames(pl$xmat) u.data <- matrix(0,nrow=length(sim.mple), ncol=num.variables) for(i in 1:length(sim.mple)){