Closed greg-fauerbach closed 2 years ago
Thanks for reporting this issue.
Indeed, the problem occurs here. The list of networks is converted there into a list of matrices using as.matrix
from the network
package, and then nrow
checks the number of rows of each matrix.
The problem seems to be that as.matrix
does not actually return a matrix. We can verify this using your example:
class(as.matrix(test_net1_bp))
returns numeric
instead of matrix
, and
dim(as.matrix(test_net1_bp))
returns NULL
.
My interpretation is that the as.matrix.network.adjacency
function in the network
package should, but doesn't, return a matrix (though I am not sure if this is the right one, given that you provided an edge list to begin with). So I'd play with the code there and see what you need to change in that function (or perhaps the other functions in that file) to get the desired effect of as.matrix
with your network
object. Perhaps worth reporting there as well as a potential bug that may need to be reviewed. Not sure what the problem is exactly, but my intuition tells me that if a function is called as.matrix
and it doesn't return a matrix, something must be wrong.
That said, I have to admit that I did not pay particular attention to edge lists and their difficulties when I wrote btergm
and tergmprepare
. So my general advice would be to use bipartite matrices when dealing with data for TERGMs. They should have n
rows and m
columns, where n
is the number of actors and m
is the number of events. This is how I would approach the problem. Let me know if you do this and there is still some issue. Admittedly, support for bipartite networks was not tested very thoroughly, but it should work. If you do have a minimal and self-contained example for that usage scenario, I would be glad if you could post it here because I could use it as a unit test in order to ensure that future changes don't break the bipartite example. Thanks.
I'll close the issue here and defer to the issue in the network
package I referenced above.
Hello,
I'm getting an error when I try to call btergm() on a list of two-mode networks where one of the modes has a single vertex.
The error I get is:
I'm almost certain the problem is occurring because R is converting each one-row sociomatrix into a numeric vector, which causes tergmprepare() to fail. When I call btergm() on a list of one-mode networks (whose sociomatrices have multiple rows and columns) it works fine.
Here's example code that reproduces the error.
Do you have any suggestions for how to solve this issue?
Thank you.