Skip to content

Commit

Permalink
Merge pull request #3 from sansan-inc/fix/komatsu/error-between
Browse files Browse the repository at this point in the history
Enable to estimate a model without externality terms
  • Loading branch information
komatsuna4747 authored Sep 14, 2021
2 parents 81f3df5 + b6e5e29 commit d426855
Show file tree
Hide file tree
Showing 7 changed files with 1,140 additions and 86 deletions.
13 changes: 7 additions & 6 deletions lighthergm/R/estimate_between_param.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ estimate_between_param <- function(formula, network, block) {
varnames <-
statnet.common::list_rhs.formula(formula) %>%
as.character()
dep_terms <- which(terms %>% purrr::map(function(t) {
dep <- t$dependence
is_dep <- is.null(dep) || dep
}) %>% unlist())
between_rhs <- varnames[-dep_terms]
between_formula <- as.formula(paste("g_logit ~ ", paste(between_rhs, collapse = " + ")))
dep_terms <-
terms %>% purrr::map(function(t) {
dep <- t$dependence
is_dep <- is.null(dep) || dep
}) %>% unlist()
between_rhs <- varnames[!dep_terms]
between_formula <- as.formula(glue::glue("g_logit ~ {paste(between_rhs, collapse = '+')}"))

# Estimate logit
between_logit <- ergm(
Expand Down
12 changes: 6 additions & 6 deletions lighthergm/R/gof_lighthergm.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ separate_formulas <- function(target_formula) {
net <- get(str_net, envir = environment(target_formula))
terms <- ergm::ergm_model(target_formula)$terms
varnames <- statnet.common::list_rhs.formula(target_formula) %>% as.character()
dep_terms <- which(terms %>% purrr::map(function(t) {
dep <- t$dependence
is_dep <- is.null(dep) || dep
}) %>% unlist())

between_rhs <- varnames[-dep_terms]
dep_terms <-
terms %>% purrr::map(function(t) {
dep <- t$dependence
is_dep <- is.null(dep) || dep
}) %>% unlist()
between_rhs <- varnames[!dep_terms]
within_rhs <- varnames

between_formula <- paste(str_net, "~", paste(between_rhs, collapse = " + "))
Expand Down
Loading

0 comments on commit d426855

Please sign in to comment.