Skip to content

Vertex attribute terms fail at extracting it #27

@mbojan

Description

@mbojan

This is a exegesis of this question on SO:

library(ergm.multi)

data(florentine, package = "ergm")

plot(flobusiness)
plot(flomarriage)

flo <- Layer(business = flobusiness, marriage = flomarriage)
set.vertex.attribute(flo, attrname = "x", value = 1:32)

flo

# Works
summary(
  flo ~ L(~ edges, ~ business) + L(~ edges, ~ marriage)
)

# Works
ergm(
  flo ~ L(~ edges, ~ business) + L(~ edges, ~ marriage)
)

# Doesn't work
summary(
  flo ~ L(~ edges + nodecov("x"), ~ business) + 
    L(~ edges + nodecov("x"), ~ marriage)
)

# Error in `ergm_Init_abort()`:
# ! In term ‘nodecov’ in package ‘ergm’ (called from term ‘L’ in package ‘ergm.multi’): ‘x’ is/are not valid nodal attribute(s).
# Run `rlang::last_trace()` to see where the error occurred.

Brief debugging suggests that the term initialization function receives the network object stripped of all the attributes, hence x above is not found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions