Skip to content

Commit

Permalink
Increased tolerances for the MPLE covariance tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
krivit committed Feb 6, 2024
1 parent b777eaf commit 30691cf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/testthat/test-mple-cov.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# Copyright 2003-2023 Statnet Commons
################################################################################

### TODO: Run some very long simulations to get more accurate reference values.

set.seed(14392)
N <- 50
y <- matrix(rbinom(N^2, 1, 0.005), N, N)
Expand All @@ -21,23 +23,23 @@ test_that("Godambe covariance method for MPLE", {
m1 <- ergm(init.sim ~ edges + triangles, estimate = "MPLE",
control=control.ergm(MPLE.covariance.method = "Godambe"))
StdErr1 <- sqrt(diag(vcov(m1)))
expect_equal(StdErr1, c(0.255, 0.059), ignore_attr = TRUE, tolerance=.01)
expect_equal(StdErr1, c(0.255, 0.059), 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",
control=control.ergm(MPLE.covariance.method = "invHess"))
StdErr2 <- sqrt(diag(vcov(m2)))
expect_equal(StdErr2, c(0.155, 0.034), ignore_attr = TRUE, tolerance=.01)
expect_equal(StdErr2, c(0.155, 0.034), ignore_attr = TRUE, tolerance=.05)
})

test_that("Bootstrap covariance method for MPLE", {
set.seed(333)
m3 <- ergm(init.sim ~ edges + triangles, estimate = "MPLE",
control=control.ergm(MPLE.covariance.method = "bootstrap"))
StdErr3 <- sqrt(diag(vcov(m3)))
expect_equal(StdErr3, c(0.257, 0.060), ignore_attr = TRUE, tolerance=.01)
expect_equal(StdErr3, c(0.257, 0.060), ignore_attr = TRUE, tolerance=.05)
})

test_that("Bootstrap covariance method for MPLE with offsets", {
Expand All @@ -46,5 +48,5 @@ test_that("Bootstrap covariance method for MPLE with offsets", {
estimate = "MPLE",
control=control.ergm(MPLE.covariance.method = "InvHess"))
StdErr4 <- sqrt(diag(vcov(m4)))
expect_equal(StdErr4, c(0.155, 0.034, 0), ignore_attr = TRUE, tolerance=.01)
expect_equal(StdErr4, c(0.155, 0.034, 0), ignore_attr = TRUE, tolerance=.05)
})

0 comments on commit 30691cf

Please sign in to comment.