我正在尝试使用函数add.edge.attribute()在R中使用statnet向network对象添加边缘属性。
下面是network对象:
> g
Network attributes:
vertices = 866
directed = TRUE
hyper = FALSE
loops = FALSE
multiple = TRUE
bipartite = FALSE
total edges= 5310
missing edges= 0
non-missing edges= 5310
Vertex attribute names:
vertex.names
Edge attribute names not shown然后我使用了add.edge.attribute(),使用下面的connections,它的长度与网络中的边数相同:
> table(connections)
favorite mention retweet
2564 2041 705
> sum(table(connections))
[1] 5310
> g <- set.edge.attribute(g, "connection_type", connections)但是,当我检查network对象时,似乎没有任何变化:
> g
Network attributes:
vertices = 866
directed = TRUE
hyper = FALSE
loops = FALSE
multiple = TRUE
bipartite = FALSE
total edges= 5310
missing edges= 0
non-missing edges= 5310
Vertex attribute names:
membership vertex.names
Edge attribute names not shown然而,当我检查get.edge.attribute()时,它似乎起作用了:
> tmp <- get.edge.attribute(g, "connection_type")
> str(tmp)
chr [1:5310] "mention" "mention" "mention" "mention" "mention" "mention" "mention" "mention" ...而且,当我尝试使用边缘属性作为ergm模型的一部分时-我尝试使用edgecov(),返回以下错误:
m1 <- ergm(g ~ edges + mutual + edgecov("connection_type"))
Error: There is no network attribute named connection_type怎么回事?为什么没有显示边属性名称?为什么它似乎不能作为ergm模型的一部分?
发布于 2020-05-26 06:30:25
m1 <- ergm(g ~ edges +相互+ edgecov(g,"connection_type"))
https://stackoverflow.com/questions/40315212
复制相似问题