Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This is a transference of the ergm-private" "control_llik" branch to the public version ergm 4.0. #337

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Added a MPLE.save.xmat control argument
Added a MPLE.save.xmat control argument to return the design matrix from the MPLE fit (if any). The current and retained default is to remove it.
  • Loading branch information
handcock committed Aug 27, 2022
commit 236c9ba7621c7085b2fda9fd3d53a561343a531b
4 changes: 4 additions & 0 deletions R/control.ergm.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
#' necessary. Note that this can be very dangerous unless you know
#' what you are doing.
#'
#' @param MPLE.save.xmat If `TRUE`, the design matrix of change statistics
#' from the pseudo-likelihood computation will be returned.
#'
#' @template control_MCMC_prop
#'
#' @param MCMC.interval Number of proposals between sampled statistics.
Expand Down Expand Up @@ -484,6 +487,7 @@ control.ergm<-function(drop=TRUE,
MPLE.nonident=c("warning","message","error"),
MPLE.nonident.tol=1e-10,
MPLE.constraints.ignore=FALSE,
MPLE.save.xmat=FALSE,

MCMC.prop=trim_env(~sparse),
MCMC.prop.weights="default", MCMC.prop.args=list(),
Expand Down
2 changes: 1 addition & 1 deletion R/ergm.R
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ ergm <- function(formula, response=NULL,
nonvar_action = control$MPLE.nonvar))
)

initialfit$xmat.full <- NULL # No longer needed but takes up space.
if(!control$MPLE.save.xmat) initialfit$xmat.full <- NULL # No longer needed but takes up space.

estimate.desc <- switch(estimate,
MPLE = if(MPLE.is.MLE) "Maximum Likelihood"
Expand Down
2 changes: 2 additions & 0 deletions R/ergm.mple.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ ergm.mple<-function(nw, fd, m, init=NULL,
mplefit.summary <- mplefit
}else{
if(MPLEtype=="logitreg"){
glm.result <- NULL
mplefit <- model.matrix(terms(pl$zy ~ .-1,data=data.frame(pl$xmat)),
data=data.frame(pl$xmat))
mplefit <- ergm.logitreg(x=mplefit, y=pl$zy, m=m, wt=pl$wend,
Expand Down Expand Up @@ -197,6 +198,7 @@ ergm.mple<-function(nw, fd, m, init=NULL,
mple.lik.null = structure(
ERRVL(try(logLik(mplefit.null), silent=TRUE), -mplefit.null$deviance/2),
nobs = nobs, df = df, class="logLik"),
glm.result = if(save.xmat) glm.result,
xmat.full = if(save.xmat) pl$xmat.full
),
class="ergm")
Expand Down
4 changes: 4 additions & 0 deletions man/control.ergm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/ergm-parallel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.