signnet
signnet: An R package for analyzing signed networks - Published in JOSS (2023)
Science Score: 98.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 9 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org, zenodo.org -
○Committers with academic emails
-
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
network-analysis
signed-networks
sna
Scientific Fields
Earth and Environmental Sciences
Physical Sciences -
40% confidence
Last synced: 4 months ago
·
JSON representation
·
Repository
R package for signed networks
Basic Info
- Host: GitHub
- Owner: schochastics
- License: other
- Language: R
- Default Branch: main
- Homepage: https://schochastics.github.io/signnet/
- Size: 6.55 MB
Statistics
- Stars: 23
- Watchers: 4
- Forks: 7
- Open Issues: 0
- Releases: 6
Topics
network-analysis
signed-networks
sna
Created over 6 years ago
· Last pushed 4 months ago
Metadata Files
Readme
Changelog
Contributing
License
Code of conduct
Citation
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# signnet
[](https://github.com/schochastics/signnet/actions)
[](https://cran.r-project.org/package=signnet)
[](https://CRAN.R-project.org/package=signnet)
[]( https://app.codecov.io/gh/schochastics/signnet?branch=main)
[](https://doi.org/10.5281/zenodo.7522563)
[](https://doi.org/10.21105/joss.04987)
The package provides methods to analyse signed networks (i.e. networks with both positive and negative ties).
## Installation
You can install the released version of signnet from CRAN with:
```{r inst, eval=FALSE}
install.packages("signnet")
```
The development version from is available with:
``` {r inst2, eval=FALSE}
# install.packages("devtools")
devtools::install_github("schochastics/signnet")
```
## Structural Balance and Triads
The principles underlying structural balance are based on a theory in social psychology dating back to the work of Heider in the 1940s, which was generalized and extended to graphs by Cartwright and Harary in the 1950s. In its simplest form, it is defined via triangles. A triangle is balanced if
all ties are positive ("the friend of a friend is a friend") or only one tie is positive ("the enemy of my enemy is my friend"). The remaining configurations are said to be unbalanced.
A network is balanced if i.a., it can be partitioned into two vertex subsets, such that intra-group edges are all positive and inter-group edges are all negative. Determining this is easy, but measuring a *degree of balancedness* (i.e. how close is a network to be balanced?) is not. The package, so far, implements three methods to calculate balance scores. All are defined such that a value of one indicates perfect balance and zero perfect unbalance. Though for intermediate networks, results may vary significantly. Check [this paper](https://doi.org/10.1093/comnet/cnx044) by Samin Aref (and his other work) for more details.
```{r balance_example,message=FALSE}
library(igraph)
library(signnet)
data("tribes")
balance_score(tribes, method = "triangles")
balance_score(tribes, method = "walk")
balance_score(tribes, method = "frustration")
```
For directed signed networks, `triad_census_signed()` can be used to compute the count for all 138 non-isomorphic signed triads.
*(The code to reproduce this figure can be found in [this gist](https://gist.github.com/schochastics/dd1974b42cfa5367cf6d8cb9e43bae32))*
# Blockmodeling
The package implements two different blockmodeling algorithms. The classic one tries to partition the
network into a specified set of groups such that intra group edges are positive and inter group edges are negative.
```{r block_code,message=FALSE}
clu <- signed_blockmodel(tribes, k = 3, alpha = 0.5, annealing = TRUE)
clu
```
The parameter *k* is the number of groups and *alpha* specifies the penalty of negative inter group and positive intra group edges.
If `alpha = 0` (`alpha = 1`) then only positive inter group (negative intra group) edges are penalized. Set `alpha = 0.5` for equal penalization
The algorithm is not exact and just a heuristic. If `annealing = TRUE`, then simulated annealing is used. This improves the result, but may take additional time.
The result of the blockmodel can be visualized with `ggblock` (requires `ggplot2`)
```{r block_example}
ggblock(tribes, clu$membership, show_blocks = TRUE, show_labels = TRUE)
```
The second blockmodeling technique is known as *generalized blockmodeling*. This method removes the restriction of positve (negative) inter (intra) group edges. Instead, a blockmatrix is passed to the function with the desired block structure. The example below illustrates the technique with a network composed of three groups with differing inter/intra group edge patterns.
```{r general_example}
# create a signed network with three groups and different inter/intra group ties
g1 <- g2 <- g3 <- graph.full(5)
V(g1)$name <- as.character(1:5)
V(g2)$name <- as.character(6:10)
V(g3)$name <- as.character(11:15)
g <- Reduce("%u%", list(g1, g2, g3))
E(g)$sign <- 1
E(g)$sign[1:10] <- -1
g <- add.edges(g, c(rbind(1:5, 6:10)), attr = list(sign = -1))
g <- add.edges(g, c(rbind(1:5, 11:15)), attr = list(sign = -1))
g <- add.edges(g, c(rbind(11:15, 6:10)), attr = list(sign = 1))
# specify the link patterns between groups
blockmat <- matrix(c(1, -1, -1, -1, 1, 1, -1, 1, -1), 3, 3, byrow = TRUE)
blockmat
clu <- signed_blockmodel_general(g, blockmat, 0.5)
clu
ggblock(g, clu$membership, show_blocks = TRUE, show_labels = FALSE)
```
# How to reach out?
### Where do I report bugs?
Simply [open an issue](https://github.com/schochastics/signnet/issues/new) on GitHub.
### How do I contribute to the package?
If you have an idea (but no code yet), [open an issue](https://github.com/schochastics/signnet/issues/new) on GitHub. If you want to contribute with a specific feature and have the code ready, fork the repository, add your code, and create a pull request.
### Do you need support?
The easiest way is to [open an issue](https://github.com/schochastics/signnet/issues/new) - this way, your question is also visible to others who may face similar problems.
### Code of Conduct
Please note that the signnet project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
Owner
- Name: David Schoch
- Login: schochastics
- Kind: user
- Location: Germany
- Company: cynkra
- Website: mr.schochastics.net
- Repositories: 131
- Profile: https://github.com/schochastics
Data Scientist/DevOps Engineer at cynkra and #RStats developer
JOSS Publication
signnet: An R package for analyzing signed networks
Published
January 27, 2023
Volume 8, Issue 81, Page 4987
Tags
network analysis signed networks structural balance theoryCitation (CITATION.cff)
# --------------------------------------------
# CITATION file created with {cffr} R package
# See also: https://docs.ropensci.org/cffr/
# --------------------------------------------
cff-version: 1.2.0
message: 'To cite package "signnet" in publications use:'
type: software
license: MIT
title: 'signnet: Methods to Analyse Signed Networks'
version: 1.0.4
doi: 10.21105/joss.04987
identifiers:
- type: doi
value: 10.32614/CRAN.package.signnet
abstract: Methods for the analysis of signed networks. This includes several measures
for structural balance as introduced by Cartwright and Harary (1956) <https://doi.org/10.1037/h0046049>,
blockmodeling algorithms from Doreian (2008) <https://doi.org/10.1016/j.socnet.2008.03.005>,
various centrality indices, and projections of signed two-mode networks introduced
by Schoch (2020) <https://doi.org/10.1080/0022250X.2019.1711376>.
authors:
- family-names: Schoch
given-names: David
email: david@schochastics.net
orcid: https://orcid.org/0000-0003-2952-4812
preferred-citation:
type: article
title: 'signnet: An R package for analyzing signed networks'
authors:
- family-names: Schoch
given-names: David
email: david@schochastics.net
orcid: https://orcid.org/0000-0003-2952-4812
doi: 10.21105/joss.04987
url: https://doi.org/10.21105/joss.04987
year: '2023'
publisher:
name: The Open Journal
volume: '8'
issue: '81'
journal: Journal of Open Source Software
start: '4987'
repository: https://CRAN.R-project.org/package=signnet
repository-code: https://github.com/schochastics/signnet
url: https://schochastics.github.io/signnet/
contact:
- family-names: Schoch
given-names: David
email: david@schochastics.net
orcid: https://orcid.org/0000-0003-2952-4812
keywords:
- network-analysis
- signed-networks
- sna
references:
- type: software
title: 'R: A Language and Environment for Statistical Computing'
notes: Depends
url: https://www.R-project.org/
authors:
- name: R Core Team
institution:
name: R Foundation for Statistical Computing
address: Vienna, Austria
year: '2024'
version: '>= 3.2.0'
- type: software
title: igraph
abstract: 'igraph: Network Analysis and Visualization'
notes: Imports
url: https://r.igraph.org/
repository: https://CRAN.R-project.org/package=igraph
authors:
- family-names: Csárdi
given-names: Gábor
email: csardi.gabor@gmail.com
orcid: https://orcid.org/0000-0001-7098-9676
- family-names: Nepusz
given-names: Tamás
email: ntamas@gmail.com
orcid: https://orcid.org/0000-0002-1451-338X
- family-names: Traag
given-names: Vincent
orcid: https://orcid.org/0000-0003-3170-3879
- family-names: Horvát
given-names: Szabolcs
email: szhorvat@gmail.com
orcid: https://orcid.org/0000-0002-3100-523X
- family-names: Zanini
given-names: Fabio
email: fabio.zanini@unsw.edu.au
orcid: https://orcid.org/0000-0001-7097-8539
- family-names: Noom
given-names: Daniel
- family-names: Müller
given-names: Kirill
email: kirill@cynkra.com
orcid: https://orcid.org/0000-0002-1416-3412
year: '2024'
doi: 10.32614/CRAN.package.igraph
- type: software
title: Matrix
abstract: 'Matrix: Sparse and Dense Matrix Classes and Methods'
notes: Imports
url: https://R-forge.R-project.org/tracker/?atid=294&group_id=61
repository: https://CRAN.R-project.org/package=Matrix
authors:
- family-names: Bates
given-names: Douglas
orcid: https://orcid.org/0000-0001-8316-9503
- family-names: Maechler
given-names: Martin
email: mmaechler+Matrix@gmail.com
orcid: https://orcid.org/0000-0002-8685-9910
- family-names: Jagan
given-names: Mikael
orcid: https://orcid.org/0000-0002-3542-2938
year: '2024'
doi: 10.32614/CRAN.package.Matrix
- type: software
title: Rcpp
abstract: 'Rcpp: Seamless R and C++ Integration'
notes: Imports
url: https://www.rcpp.org
repository: https://CRAN.R-project.org/package=Rcpp
authors:
- family-names: Eddelbuettel
given-names: Dirk
email: edd@debian.org
orcid: https://orcid.org/0000-0001-6419-907X
- family-names: Francois
given-names: Romain
orcid: https://orcid.org/0000-0002-2444-4226
- family-names: Allaire
given-names: JJ
orcid: https://orcid.org/0000-0003-0174-9868
- family-names: Ushey
given-names: Kevin
orcid: https://orcid.org/0000-0003-2880-7407
- family-names: Kou
given-names: Qiang
orcid: https://orcid.org/0000-0001-6786-5453
- family-names: Russell
given-names: Nathan
- family-names: Ucar
given-names: Iñaki
orcid: https://orcid.org/0000-0001-6403-5550
- family-names: Bates
given-names: Doug
orcid: https://orcid.org/0000-0001-8316-9503
- family-names: Chambers
given-names: John
year: '2024'
doi: 10.32614/CRAN.package.Rcpp
- type: software
title: ggplot2
abstract: 'ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics'
notes: Suggests
url: https://ggplot2.tidyverse.org
repository: https://CRAN.R-project.org/package=ggplot2
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
orcid: https://orcid.org/0000-0003-4757-117X
- family-names: Chang
given-names: Winston
orcid: https://orcid.org/0000-0002-1576-2126
- family-names: Henry
given-names: Lionel
- family-names: Pedersen
given-names: Thomas Lin
email: thomas.pedersen@posit.co
orcid: https://orcid.org/0000-0002-5147-4711
- family-names: Takahashi
given-names: Kohske
- family-names: Wilke
given-names: Claus
orcid: https://orcid.org/0000-0002-7470-9261
- family-names: Woo
given-names: Kara
orcid: https://orcid.org/0000-0002-5125-4188
- family-names: Yutani
given-names: Hiroaki
orcid: https://orcid.org/0000-0002-3385-7233
- family-names: Dunnington
given-names: Dewey
orcid: https://orcid.org/0000-0002-9415-4582
- family-names: Brand
given-names: Teun
name-particle: van den
orcid: https://orcid.org/0000-0002-9335-7468
year: '2024'
doi: 10.32614/CRAN.package.ggplot2
- type: software
title: knitr
abstract: 'knitr: A General-Purpose Package for Dynamic Report Generation in R'
notes: Suggests
url: https://yihui.org/knitr/
repository: https://CRAN.R-project.org/package=knitr
authors:
- family-names: Xie
given-names: Yihui
email: xie@yihui.name
orcid: https://orcid.org/0000-0003-0645-5666
year: '2024'
doi: 10.32614/CRAN.package.knitr
- type: software
title: rmarkdown
abstract: 'rmarkdown: Dynamic Documents for R'
notes: Suggests
url: https://pkgs.rstudio.com/rmarkdown/
repository: https://CRAN.R-project.org/package=rmarkdown
authors:
- family-names: Allaire
given-names: JJ
email: jj@posit.co
- family-names: Xie
given-names: Yihui
email: xie@yihui.name
orcid: https://orcid.org/0000-0003-0645-5666
- family-names: Dervieux
given-names: Christophe
email: cderv@posit.co
orcid: https://orcid.org/0000-0003-4474-2498
- family-names: McPherson
given-names: Jonathan
email: jonathan@posit.co
- family-names: Luraschi
given-names: Javier
- family-names: Ushey
given-names: Kevin
email: kevin@posit.co
- family-names: Atkins
given-names: Aron
email: aron@posit.co
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
- family-names: Cheng
given-names: Joe
email: joe@posit.co
- family-names: Chang
given-names: Winston
email: winston@posit.co
- family-names: Iannone
given-names: Richard
email: rich@posit.co
orcid: https://orcid.org/0000-0003-3925-190X
year: '2024'
doi: 10.32614/CRAN.package.rmarkdown
- type: software
title: testthat
abstract: 'testthat: Unit Testing for R'
notes: Suggests
url: https://testthat.r-lib.org
repository: https://CRAN.R-project.org/package=testthat
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
year: '2024'
doi: 10.32614/CRAN.package.testthat
version: '>= 2.1.0'
- type: software
title: RcppArmadillo
abstract: 'RcppArmadillo: ''Rcpp'' Integration for the ''Armadillo'' Templated Linear
Algebra Library'
notes: LinkingTo
url: https://dirk.eddelbuettel.com/code/rcpp.armadillo.html
repository: https://CRAN.R-project.org/package=RcppArmadillo
authors:
- family-names: Eddelbuettel
given-names: Dirk
email: edd@debian.org
orcid: https://orcid.org/0000-0001-6419-907X
- family-names: Francois
given-names: Romain
orcid: https://orcid.org/0000-0002-2444-4226
- family-names: Bates
given-names: Doug
orcid: https://orcid.org/0000-0001-8316-9503
- family-names: Ni
given-names: Binxiang
- family-names: Sanderson
given-names: Conrad
orcid: https://orcid.org/0000-0002-0049-4501
year: '2024'
doi: 10.32614/CRAN.package.RcppArmadillo
GitHub Events
Total
- Watch event: 1
- Push event: 9
- Pull request event: 3
- Fork event: 1
- Create event: 1
Last Year
- Watch event: 1
- Push event: 9
- Pull request event: 3
- Fork event: 1
- Create event: 1
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| schochastics | d****d@s****t | 143 |
| Arthur Mühl | a****l@g****g | 2 |
| robertjankowski | r****1@w****l | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 23
- Total pull requests: 6
- Average time to close issues: 5 months
- Average time to close pull requests: 2 days
- Total issue authors: 7
- Total pull request authors: 3
- Average comments per issue: 1.65
- Average comments per pull request: 0.17
- Merged pull requests: 6
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 3
- Average time to close issues: N/A
- Average time to close pull requests: 4 days
- Issue authors: 0
- Pull request authors: 2
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 3
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- cosimameyer (9)
- schochastics (7)
- vlabatut (3)
- caoyang12 (1)
- Zygodon (1)
- conradsnicta (1)
- alexpghayes (1)
Pull Request Authors
- schochastics (5)
- ArthurMuehl (1)
- robertjankowski (1)
Top Labels
Issue Labels
enhancement (4)
bug (2)
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 423 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 15
- Total maintainers: 1
cran.r-project.org: signnet
Methods to Analyse Signed Networks
- Homepage: https://github.com/schochastics/signnet
- Documentation: http://cran.r-project.org/web/packages/signnet/signnet.pdf
- License: MIT + file LICENSE
-
Latest release: 1.0.5
published 11 months ago
Rankings
Forks count: 10.1%
Stargazers count: 11.9%
Average: 23.8%
Dependent packages count: 29.8%
Downloads: 31.7%
Dependent repos count: 35.5%
Maintainers (1)
Last synced:
4 months ago
Dependencies
DESCRIPTION
cran
- R >= 3.2.0 depends
- Matrix * imports
- Rcpp * imports
- igraph * imports
- ROI * suggests
- ROI.plugin.glpk * suggests
- covr * suggests
- ggplot2 * suggests
- ggraph * suggests
- knitr * suggests
- ompr * suggests
- ompr.roi * suggests
- rmarkdown * suggests
- testthat >= 2.1.0 suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v3 composite
- actions/upload-artifact v3 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
