Skip to content

Commit

Permalink
Tweaked the tolerance of the curved ERGM partial offset test.
Browse files Browse the repository at this point in the history
  • Loading branch information
krivit committed Mar 8, 2024
1 parent 2d39d82 commit 35ae128
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/testthat/test-offsets.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ data(sampson)
total.theta <- coef(ergm(samplike~edges))
offset.theta <- pi

wald_pval <- function(fit1, fit2, i1=TRUE, i2=TRUE){
d <- coef(fit1)[i1] - coef(fit2)[i2]
df <- length(d)
vcov <- vcov(fit1, sources="estimation")[i1,i1] + vcov(fit2, sources="estimation")[i2,i2]
pchisq(d %*% solve(vcov) %*% d, df, lower.tail=FALSE)
}

test_that("Linear ERGM with free parameter before offset", {
e1 <- ergm(samplike~edges+offset(edges), offset.coef=c(pi))
expect_equal(coef(e1)[1], total.theta-offset.theta, tolerance=0.00001, ignore_attr=TRUE)
Expand All @@ -40,7 +47,7 @@ test_that("Linear ERGM with partial offsets", {
test_that("Curved ERGM with partial offsets", {
e4 <- ergm(samplike~edges+gwesp(0.25, fix=TRUE), control=control.ergm(seed=0,MCMLE.maxit=2))
e4a <- ergm(samplike~edges+offset(gwesp(),c(FALSE,TRUE)), offset.coef=0.25, control=control.ergm(seed=0,MCMLE.maxit=2))
expect_equal(coef(e4a)[-3], coef(e4), tolerance=0.06, ignore_attr=TRUE)
expect_gt(wald_pval(e4a, e4, -3, TRUE), 0.01)
expect_equal(logLik(e4a), logLik(e4), tolerance=0.01, ignore_attr=TRUE)
})

Expand Down

0 comments on commit 35ae128

Please sign in to comment.