Removes actors whose nodal_data carries NA in one or more
covariate columns. ERGM terms like nodecov() and
nodematch() reject NA-bearing vertex attributes, so this helper
is handy upstream of netify_to_statnet. Works for
cross-sectional, longitudinal, and bipartite netlets.
Value
A netify object equivalent to
subset_netify(netlet, actors = clean_actors) after dropping
any actor whose nodal rows contain NA in the inspected
columns. If no NAs are found the input is returned unchanged.
Details
For longitudinal netlets an actor is dropped from every period if any
of its rows in nodal_data carry NA in the inspected
columns. For bipartite netlets only actors in the mode that the
nodal table covers are filtered; the other mode passes through
untouched.
Corner cases:
If
colsreferences a name that is not innodal_data, the call aborts with a clear message listing the missing columns.If no actor carries
NAin the inspected columns, the input netlet is returned unchanged (no inform).If every actor carries
NA(so the cleaned netlet would have zero actors), the call aborts rather than silently returning an empty netify, which would break downstreamto_statnet()/ergm()pipelines.If the netlet has no
nodal_dataattribute attached, the input is returned unchanged.
Examples
# \donttest{
data(icews)
net <- netify(
icews,
actor1 = "i", actor2 = "j", time = "year",
symmetric = FALSE, weight = "verbCoop",
nodal_vars = c("i_polity2", "i_log_gdp", "i_log_pop")
)
clean <- drop_na_actors(net, cols = c("i_polity2", "i_log_gdp"))
#> ℹ Dropped 8 of 152 actors with NA covariates: "Afghanistan", "Bosnia And
#> Herzegovina", "Djibouti", "Iraq", "Korea, Democratic People's Republic Of",
#> "Lebanon", "Solomon Islands", and "Somalia".
#> This message is displayed once per session.
# }