Skip to content

Commit

Permalink
Merge pull request #562 from statnet/i561-mplecov
Browse files Browse the repository at this point in the history
Remove unecesary lines from ergm_mplecov()
  • Loading branch information
krivit authored Jun 13, 2024
2 parents 90020d2 + 49d372d commit aaf1ffb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 0 additions & 2 deletions R/ergm_mplecov.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/test-mple-cov.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)
})


0 comments on commit aaf1ffb

Please sign in to comment.