statnet / ergm

Fit, Simulate and Diagnose Exponential-Family Models for Networks
Other
98 stars 37 forks source link

ergm constraints=~bd(minin=..., minout=...) throw error when supplying a vector #530

Closed benrosche closed 1 year ago

benrosche commented 1 year ago

When using a vector of length n.nodes to constrain the minimum in- or outdegree, the ergm function throws an error. This does not happen for maxin or maxout.

This minimally reproducible example:

ergm(network(10, directed = T) ~ edges, constraint=~bd(minin=rep(1,10)))

results in the following error:

Error in is.na(a$minout) && is.na(a$minin): 'length = 10' in coercion to 'logical(1)'

I believe the problem lies in the way missing values are assessed.

I used ergm version 4.4.0, R Studio 2023.03.1, and R version 4.3.0.

krivit commented 1 year ago

Looks like a longstanding bug that was exposed by R 4.3.0's || and && now raising an error if given a vector of length greater than 1. Thanks for the report!