[statnet_help] Assistance with Calculating Degree Centrality in Directed and Valued Networks Using the sna Package in R

Carter T. Butts via statnet_help statnet_help at u.washington.edu
Sat Aug 24 14:15:38 PDT 2024


H, Chuding -

The degree() function already exploits edge values; this is its default
behavior.  If you wish to /ignore/ edge values, you need to set the
"ignore.eval" argument to TRUE.

If you are not getting valued degree calculations from degree() using
the defaults, then you are not passing it valued data.  This may be due
to a preprocessing error (so check your inputs). Another possible
failure mode is that you are passing it a network object that has value
information stored as an edge attribute, and are expecting degree() to
use those edge values.  Since a network object can have any number of
edge attributes (or none at all), and they can be of any data type
(i.e., not necessarily numeric), degree() can't automagically know what
is intended in that case, and will therefore treat the data as
unvalued.  An easy way to use edge attribute information is to wrap your
object in a call like
as.edgelist.sna(<mynet>,attrname=<whateveredgeattributeIwanttouse>),
which will extract from the object the specific valued network that you
want to analyze.  That's especially handy if you have several different
edge values you want to store in the same network object.  Of course,
you can also use that same trick to make a "working" edgelist at the top
of your script that you reuse for multiple calculations.  (The same can
be done with adjacency matrices rather than edgelists, if one prefers. 
See e.g. ?as.sociomatrix.sna.)

Hope that helps,

-Carter

On 8/23/24 9:07 PM, CHU-DING LING via statnet_help wrote:

>

> Dear all,

>

> I hope this message finds you well. I am currently working on a

> project that involves social network analysis using the *sna* package

> in R. I am reaching out to seek your expertise on a particular issue I

> have encountered regarding the calculation of degree centrality in

> directed and valued networks.

>

> I am working with a directed network where edges have associated

> weights. My goal is to accurately calculate both the in-degree and

> out-degree centrality of nodes while considering the edge weights. I

> attempted to calculate the degree centrality using the degree function

> in the *sna* package. While this function works well for unweighted

> networks, I realized that it does not account for edge weights.

>

> Could you please advise on the best method or function within the

> *sna* package to accurately calculate the degree centrality in this

> context? Though I can make it with *igraph* or other packages, I am

> particularly interested in whether *sna* could directly handle

> weighted edges in directed networks.

>

> Your guidance would be invaluable, and I would greatly appreciate any

> suggestions or resources you might be able to provide. Thank you for

> your time and consideration. I look forward to your insights.

>

> Best,

>

> Chuding

>

>

> _______________________________________________

> statnet_help mailing list

> statnet_help at u.washington.edu

> https://urldefense.com/v3/__http://mailman13.u.washington.edu/mailman/listinfo/statnet_help__;!!CzAuKJ42GuquVTTmVmPViYEvSg!Npw4CFqLg3mWAfPesSBtoa6UjvVqK_t7JYrixPsjqKAxzUTjhOvoeAxG6tO4iWruplppJ7ZQGd8FOLXV8VLxBP8-nfnt$

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman13.u.washington.edu/pipermail/statnet_help/attachments/20240824/aa9f9e9d/attachment.html>


More information about the statnet_help mailing list