Skip to content

Commit

Permalink
Use ergm 4.7 API for renaming terms.
Browse files Browse the repository at this point in the history
  • Loading branch information
krivit committed Oct 8, 2024
1 parent c24e7ac commit c264bd1
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions R/InitErgmTerm.EGMME.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,6 @@ InitErgmTerm..union.lt.net<-function(nw, arglist, ...) {
list(emptynwstats=NULL)))
}

### TODO: Export this from ergm then remove from tergm.
ergm_rename_terms <- function(model, namewrap){
for(i in seq_along(model$terms)){
model$terms[[i]]$coef.names <- namewrap(model$terms[[i]]$coef.names)
if(!is.null(model$terms[[i]]$params)) names(model$terms[[i]]$params) <- namewrap(names(model$terms[[i]]$params))
}
model
}

`InitErgmTerm.Cross (dynamic)` <- function(nw, arglist, ...) {
stopifnot_dynamic(nw, .netseries.OK=TRUE, ...)
Expand All @@ -144,8 +136,10 @@ ergm_rename_terms <- function(model, namewrap){
defaultvalues = list(NULL),
required = c(TRUE))

ergm_model(a$formula, nw, ..., terms.only=TRUE) %>%
ergm_rename_terms(function(x) paste0("Cross~", x))
m <- ergm_model(a$formula, nw, ..., terms.only=TRUE)
param_names(m) <- list(paste0("Cross~", param_names(m, canonical = FALSE)),
paste0("Cross~", param_names(m, canonical = TRUE)))
m
}


Expand Down

0 comments on commit c264bd1

Please sign in to comment.