leifeld / btergm

Temporal Exponential Random Graph Models by Bootstrapped Pseudolikelihood
16 stars 10 forks source link

check degeneracy #28

Closed daevra closed 2 years ago

daevra commented 2 years ago

Hello,

I'm currently working on some research using the bterg model, and am encountering an issue when I try to run a degeneracy check on my btergm object. I've tried finding a solution elsewhere, but to no avail. I'm fairly new to programming so I'm not entirely sure if the problem is on my end or with the program itself. So far, my code runs smoothly for estimating the btergm and for checking gof. However, once I attempt to run the degeneracy check on the btergm object using the code in the documentation:

checkdegeneracy( object, nsim = 1000, MCMC.interval = 1000, MCMC.burnin = 10000, verbose = FALSE )

I receive the following error code: image

Is there something that I'm missing? I've double checked to make sure that the object is a btergm object and it is. I've also tried with different data and still experienced the same issue.

Thank you so much for the help and your time!

leifeld commented 2 years ago

Thanks. I can confirm there is something off. Here is a minimal example:

library("network")
library("btergm")
set.seed(5)

networks <- list()
for (i in 1:10) {          # create 10 random networks with 10 actors
  mat <- matrix(rbinom(100, 1, .25), nrow = 10, ncol = 10)
  diag(mat) <- 0           # loops are excluded
  nw <- network(mat)       # create network object
  networks[[i]] <- nw      # add network to the list
}

covariates <- list()
for (i in 1:10) {          # create 10 matrices as covariate
  mat <- matrix(rnorm(100), nrow = 10, ncol = 10)
  covariates[[i]] <- mat   # add matrix to the list
}

fit <- btergm(networks ~ edges + istar(2) + edgecov(covariates), R = 100)

checkdegeneracy(fit)

The part that causes the problem is the following command in Line 119 in the checkdegeneracy.R file:

    target.stats[[index]] <- summary(statnet.common::filter_rhs.formula(form),
        response = NULL)

I will look into this next time I work on the package.

leifeld commented 2 years ago

Thanks again for the bug report. It should work now. If it doesn't, please let me know here.

daevra commented 2 years ago

Hi Philip,

Thank you for working on this. Unfortunately, I'm still receiving the same error message when running the BTERG model. I've gone through all the normal steps to try to solve the problem (i.e., restarting R; uninstalling/reinstalling the package; etc.). Thanks again for your help.

leifeld commented 2 years ago

Weird. Okay, let's try to diagnose this together. What's your output of packageVersion("btergm") after restarting R?

daevra commented 2 years ago

I'm getting 1.10.3

leifeld commented 2 years ago

That looks like the old version before I updated it. Can you please install the latest version from GitHub using the install_github function in the remotes package and try again?

daevra commented 2 years ago

okay runs great! thanks a lot for your assistance!

leifeld commented 2 years ago

Excellent! No problem!