From 140c76276a6cb5bfad89f84afb6c618be4810d2d Mon Sep 17 00:00:00 2001
From: "Pavel N. Krivitsky"
Date: Fri, 26 Jan 2024 19:48:40 +1100
Subject: [PATCH] In ergm.MCMLE() for missing data, guard against constrained
variance being higher than unconstrained on a particular interation by
treating the difference as 0 instead.
---
R/ergm.MCMLE.R | 2 ++
1 file changed, 2 insertions(+)
diff --git a/R/ergm.MCMLE.R b/R/ergm.MCMLE.R
index a205f1094..406c93be8 100644
--- a/R/ergm.MCMLE.R
+++ b/R/ergm.MCMLE.R
@@ -315,6 +315,8 @@ ergm.MCMLE <- function(init, s, s.obs,
estdiff <- NVL3(esteq.obs, colMeans(.), 0) - colMeans(esteq)
pprec <- diag(sqrt(control$MCMLE.MCMC.precision), nrow=length(estdiff))
Vm <- pprec%*%(cov(esteq) - NVL3(esteq.obs, cov(.), 0))%*%pprec
+ novar <- diag(Vm) <= 0
+ Vm[,novar] <- Vm[novar,] <- 0
d2 <- xTAx_seigen(estdiff, Vm)
if(d2<2) last.adequate <- TRUE
}