-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Robustified MCMLE estimation and MCMC error calculation against the s…
…ituation in which the observational process results in a constant sufficient statistic in the constrained MCMC sample and added a test.
- Loading branch information
Showing
4 changed files
with
39 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
tolerance <- 4 # Result must be within 4*MCMCSE of truth. | ||
|
||
data(florentine) | ||
|
||
test_that("Missing data MLE with edge observational constraint", { | ||
n.active <- network.dyadcount(flomarriage) - network.edgecount(flobusiness) | ||
e.active <- network.edgecount(flomarriage) - network.edgecount(flomarriage&flobusiness) | ||
p.active <- e.active/n.active | ||
theta <- logit(p.active) | ||
mcmcfit <- suppressWarnings(ergm(flomarriage~edges, constraints = ~fixedas(flobusiness), obs.constraints = ~edges)) | ||
|
||
## Point estimate | ||
expect_lt(abs(theta-coef(mcmcfit))/sqrt(diag(vcov(mcmcfit, source="estimation"))), tolerance) | ||
|
||
## Likelihood | ||
# Relative to NULL model, whose likelihood is defined to be 0. | ||
llk <- log(p.active)*e.active+log(1-p.active)*(n.active-e.active) - log(.5)*n.active | ||
expect_lt(abs(llk-logLik(mcmcfit))/sqrt(attr(logLik(mcmcfit), "vcov")), tolerance) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters