npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dwh

v0.3.0

Published

## Overview

Downloads

4

Readme

DWH

Overview

Degree-weighted homophily (DWH) is a measure of similarity between nodes in a network based on their attributes (such as demographic characteristics or behaviors) and their degree (i.e., the number of connections they have to other nodes in the network). It is used to quantify the extent to which nodes with similar attributes tend to be connected to each other more frequently than would be expected by chance.

DWH is calculated as the ratio of the observed number of connections between nodes with similar attributes to the expected number of connections between such nodes, based on their degree.

In mathematical terms, it is defined as: $DWH = (W_M + W_C - 2*W_X) / (d_{in}/nodes_{in}/nodes_{in} + d_{out}/nodes_{out}/nodes_{out} )$

Where:

  • $W_M$ : Weight of in-group connections
  • $W_C$ : Weight of out-group connections
  • $W_X$ : Weight of cross-group connections
  • $d_{in}$ : In-group degree
  • $d_{out}$ : Out-group degree
  • $nodes_{in}$ : number of in-group nodes
  • $nodes_{out}$ : number of out-group nodes

DWH ranges from -1 to 1. A DWH value of 0 indicates that there is no more homophily than expected with chance, while a value of 1 indicates that there is perfect homophily (e.g. Birds always link to birds). A value of -1 is achieved for perfectly disassortative networks (e.g. Bird never linking with another bird).

DWH is used in social network analysis and in the study of how different attributes are related to the formation of connections between individuals. It is used as a way to measure the similarity of attributes between individuals in a network.

Please see Benjamin Golub, Matthew O. Jackson, How Homophily Affects the Speed of Learning and Best-Response Dynamics, The Quarterly Journal of Economics, Volume 127, Issue 3, August 2012, Pages 1287–1338 for more information

Usage

computeDWH takes four arguments:

  • network: A network JSON that is the result from the HIV-TRACE package. Additionally, the results from hivtrace must be annotated using hivnetworkannotate from the hivclustering package.
  • binBy: A function that is used to bin the nodes in the network into different groups based on a specific attribute. An example function can be found in bin/dws.js.
  • value: This argument is the value that is used to filter the nodes in the network. The function binBy is applied to each node in the network, and the nodes are filtered based on whether the result of this function is equal to the value provided. For example, if one wants to know the DWH of attribute "Bird", this argument would be "Bird"
  • randomize: This argument is a Boolean value that determines whether the nodes in the network will be shuffled randomly before the computation of DWH. If the value is true, the nodes will be shuffled, and if the value is false, the nodes will not be shuffled. This is to determine the null distribution.