netmem
'netmem: Network Measures using Matrices' is an R Package
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
✓Academic publication links
Links to: springer.com -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.6%) to scientific vocabulary
Keywords
matrices
multilayer-networks
network-analysis
network-science
r
r-package
rstats
sna
social-network
social-network-analysis
sociology
Last synced: 6 months ago
·
JSON representation
Repository
'netmem: Network Measures using Matrices' is an R Package
Basic Info
- Host: GitHub
- Owner: anespinosa
- License: other
- Language: R
- Default Branch: main
- Homepage: https://anespinosa.github.io/netmem/
- Size: 12.2 MB
Statistics
- Stars: 12
- Watchers: 1
- Forks: 0
- Open Issues: 17
- Releases: 1
Topics
matrices
multilayer-networks
network-analysis
network-science
r
r-package
rstats
sna
social-network
social-network-analysis
sociology
Created almost 6 years ago
· Last pushed 10 months ago
Metadata Files
Readme
License
Code of conduct
Codemeta
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# netmem: Network Measures using Matrices
[](https://CRAN.R-project.org/package=netmem)
[](https://anespinosa.r-universe.dev/netmem)
[](https://github.com/https://github.com/anespinosa/netmem)
[](https://www.tidyverse.org/lifecycle/#experimental)
[](https://codecov.io/gh/anespinosa/netmem?branch=master)
[](https://www.codefactor.io/repository/github/anespinosa/netmem)
[](https://ci.appveyor.com/project/anespinosa/netmem)
[](https://github.com/anespinosa/netmem/actions/workflows/R-CMD-check.yaml)
[](https://www.gnu.org/licenses/gpl-3.0)
[]()
The goal of [`netmem`](https://anespinosa.github.io/netmem/) is to make
available different measures to analyse and manipulate complex networks using
matrices.
```{r, echo=FALSE, message=FALSE, warning=FALSE}
# Check if the 'devtools' package is installed
if (!requireNamespace("devtools", quietly = TRUE)) {
install.packages("devtools")
}
# Check if the 'emo' package is installed via devtools
if (!requireNamespace("emo", quietly = TRUE)) {
devtools::install_github("hadley/emo")
}
```
`r emo::ji("pen")` Author/mantainer: [Alejandro
Espinosa-Rada](https://www.aespinosarada.com)
`r emo::ji("school")` [Current: Institute of Sociology, Pontificia Universidad Católica de Chile](https://sociologia.uc.cl)
`r emo::ji("school")` [Before: Social Networks Lab, ETH Zürich](https://sn.ethz.ch)
[](https://x.com/aespinosarada)
The package implements different measures to analyse and manipulate complex
multilayer networks, from an ego-centric perspective, considering one-mode
networks, valued ties (i.e. *weighted* or *multiplex*) or with multiple levels.
## Citation
```{r echo=FALSE, results='asis'}
citation(package = "netmem")
```
## Functions currently available in [`netmem`](https://anespinosa.github.io/netmem/reference/index.html):
Utilities:
1. `matrix_report()`: Matrix report
2. `matrix_adjlist()`: Transform a matrix into an adjacency list
3. `matrix_projection()`: Unipartite projections
4. `matrix_to_edgelist()`: Transform a square matrix into an edge-list
5. `adj_to_matrix()`: Transform an adjacency list into a matrix
6. `adj_to_incidence()`: Transform an adjacency matrix into a incidence matrix
7. `cumulativeSumMatrices()`: Cumulative sum of matrices
8. `edgelist_to_matrix()`: Transform an edgelist into a matrix
9. `expand_matrix()`: Expand matrix
10. `extract_component()`: Extract components
11. `hypergraph()`: Hypergraphs
12. `perm_matrix()`: Permutation matrix
13. `perm_label()`: Permute labels of a matrix
14. `power_function()`: Power of a matrix
15. `meta_matrix()`: Meta matrix for multilevel networks
16. `minmax_overlap()`: Minimum/maximum overlap
17. `mix_matrix()`: Mixing matrix
18. `simplicial_complexes()`: Simplicial complexes
19. `structural_na()`: Structural missing data
20. `ego_net()`: Ego network
21. `zone_sample()`: Zone-2 sampling from second-mode
Ego and personal networks:
1. `eb_constraint()`: Constraint
2. `ei_index()`: Krackhardt and Stern's E-I index
3. `heterogeneity()`: Blau's and IQV index
4. `redundancy()`: Redundancy measures
Path distances:
1. `bfs_ugraph()`: Breath-first algorithm
2. `compound_relation()`: Relational composition
3. `count_geodesics()`: Count geodesic distances
4. `short_path()`: Shortest path
5. `wlocal_distances()`: Dijikstra's algorithm (one actor)
6. `wall_distances()`: Dijikstra's algorithm (all actors)
Signed networks:
1. `posneg_index()`: Positive-negative centrality
2. `struc_balance()`: Structural balance
Structural measures:
1. `gen_density()`: Generalized density
2. `gen_degree()`: Generalized degree
3. `multilevel_degree()`: Degree centrality for multilevel networks
4. `recip_coef()`: Reciprocity
5. `trans_coef()`: Transitivity
6. `trans_matrix()`: Transitivity matrix
7. `components_id()`: Components
8. `k_core()`: Generalized k-core
9. `dyadic_census()`: Dyad census
10. `multiplex_census()`: Multiplex triad census
11. `mixed_census()`: Multilevel triad and quadrilateral census
Cohesive subgroups:
1. `clique_table()`: Clique table
2. `dyad_triad_table()`: Forbidden triad table
3. `percolation_clique()`: Clique percolation
4. `q_analysis()`: Q-analysis
5. `shared_partners()`: Shared partners
Similarity measures:
1. `bonacich_norm()`: Bonacich normalization
2. `co_ocurrence()`: Co‐occurrence
3. `dist_sim_matrix()`: Structural similarities
4. `fractional_approach()`: Fractional approach
5. `jaccard()`: Jaccard similarity
Network inference:
1. `kp_reciprocity()`: Reciprocity of Katz and Powell
2. `z_arctest()`: Z test of the number of arcs
3. `triad_uman()`: Triad census analysis assuming U|MAN
4. `ind_rand_matrix()`: Independent random matrix
Geographic information:
1. `dist_geographic()`: Geographical distances
2. `spatial_cor()`: Spatial autocorrelation
Data currently available:
1. `FIFAego`: Ego FIFA
2. `FIFAex`: Outside FIFA
3. `FIFAin`: Inside FIFA
4. `krackhardt_friends`: Krackhardt friends
5. `lazega_lawfirm`: Lazega Law Firm
Additional data in [`classicnets: Classic Data of Social
Networks`](https://github.com/anespinosa/classicnets)
-----
# Quick overview of `netmem: Network Measures using Matrices`
-----
## Installation
You can install the development version from [GitHub](https://github.com/)
with:
```{r inst, eval=FALSE}
### OPTION 1
# install.packages("devtools")
devtools::install_github("anespinosa/netmem")
### OPTION 2
options(repos = c(
netmem = "https://anespinosa.r-universe.dev",
CRAN = "https://cloud.r-project.org"
))
install.packages("netmem")
```
```{r inst2}
library(netmem)
```
-----
## Multilevel Networks
Connections between individuals are often embedded in complex structures, which
shape actors’ expectations, behaviours and outcomes over time. These structures
can themselves be interdependent and exist at different levels. Multilevel
networks are a means by which we can represent this complex system by using
nodes and edges of different types. Check [this
book](https://www.springer.com/gp/book/9783319245188) edited by Emmanuel Lazega
and Tom A.B. Snijders or [this
book](https://www.cambridge.org/core/books/multimodal-political-networks/43EE8C192A1B0DCD65B4D9B9A7842128)
edited by David Knoke, Mario Diani, James Hollway and Dimitris Christopoulos.
For multilevel structures, we tend to collect the data in different matrices
representing the variation of ties within and between levels. Often, we describe
the connection between actors as an adjacency matrix and the relations between
levels through incidence matrices. The comfortable combination of these matrices
into a common structure would represent the multilevel network that could be
highly complex.
### Example
Let's assume that we have a multilevel network
with two adjacency matrices, one valued matrix and two incidence matrices
between them.
- `A1`: Adjacency Matrix of the level 1
- `B1`: incidence Matrix between level 1 and level 2
- `A2`: Adjacency Matrix of the level 2
- `B2`: incidence Matrix between level 2 and level 3
- `A3`: Valued Matrix of the level 3
Create the data
```{r multilevel_example}
A1 <- matrix(c(
0, 1, 0, 0, 1,
1, 0, 0, 1, 1,
0, 0, 0, 1, 1,
0, 1, 1, 0, 1,
1, 1, 1, 1, 0
), byrow = TRUE, ncol = 5)
B1 <- matrix(c(
1, 0, 0,
1, 1, 0,
0, 1, 0,
0, 1, 0,
0, 1, 1
), byrow = TRUE, ncol = 3)
A2 <- matrix(c(
0, 1, 1,
1, 0, 0,
1, 0, 0
), byrow = TRUE, nrow = 3)
B2 <- matrix(c(
1, 1, 0, 0,
0, 0, 1, 0,
0, 0, 1, 1
), byrow = TRUE, ncol = 4)
A3 <- matrix(c(
0, 1, 3, 1,
1, 0, 0, 0,
3, 0, 0, 5,
1, 0, 5, 0
), byrow = TRUE, ncol = 4)
```
We will start with a report of the matrices:
```{r matrix_report}
matrix_report(A1)
matrix_report(B1)
matrix_report(A2)
matrix_report(B2)
matrix_report(A3)
```
What is the density of some of the matrices?
```{r multilevel_example2}
matrices <- list(A1, B1, A2, B2)
gen_density(matrices, multilayer = TRUE)
```
How about the degree centrality of the entire structure?
```{r multil, warning=FALSE}
multilevel_degree(A1, B1, A2, B2, complete = TRUE)
```
Besides, we can perform a *k*-core analysis of one of the levels using the
information of an incidence matrix
```{r multil2, warning=FALSE}
k_core(A1, B1, multilevel = TRUE)
```
This package also allows performing complex census for multilevel networks.
```{r multil3}
mixed_census(A2, t(B1), B2, quad = TRUE)
```
-----
### Ego measures
When we are interested in one particular actor, we could perform different
network measures. For example, actor `e` has connections with all the other
actors in the network. Therefore, we could estimate some of Ronald Burt's
measures.
```{r ego}
# First we will assign names to the matrix
rownames(A1) <- letters[1:nrow(A1)]
colnames(A1) <- letters[1:ncol(A1)]
eb_constraint(A1, ego = "e")
redundancy(A1, ego = "e")
```
Also, sometimes we might want to subset a group of actors surrounding an ego.
```{r ego2}
ego_net(A1, ego = "e")
```
-----
### One-mode network
This package expand some measures for one-mode networks, such as the generalized
degree centrality. Suppose we consider a valued matrix `A3`. If `alpha=0` then
it would only count the direct connections. But, adding the tuning parameter
`alpha=0.5` would determine the relative importance of the number of ties
compared to tie weights.
```{r onem}
gen_degree(A3, digraph = FALSE, weighted = TRUE)
```
Also, we could conduct some exploratory analysis using the normalized degree of
an incidence matrix.
```{r onem2}
gen_degree(B1, bipartite = TRUE, normalized = TRUE)
```
This package also implements some analysis of dyads.
```{r onem3}
# dyad census
dyadic_census(A1)
# Katz and Powell reciprocity
kp_reciprocity(A1)
# Z test of the number of arcs
z_arctest(A1)
```
We can also check the triad census assuming conditional uniform distribution
considering different types of dyads **(U|MAN)**
```{r onem4}
triad_uman(A1)
```
-----
### Code of conduct
Please note that this project is released with a [Contributor Code of
Conduct](https://anespinosa.github.io/netmem/CODE_OF_CONDUCT.html). By
participating in this project you agree to abide by its terms.
-----
### To-do list
```{r todo1}
# library(todor)
# todor::todor_package(c("TODO", "FIXME"))
```
-----
### Other related R packages
- [`{bipartite}`](https://github.com/biometry/bipartite)
- [`{migraph}`](https://github.com/snlab-ch/migraph)
- [`{multinet}`](https://CRAN.R-project.org/package=multinet)
- [`{muxViz}`](https://github.com/manlius/muxViz)
- [`{tnet}`](https://toreopsahl.com/tnet/)
- [`{xUCINET}`](https://www.analyzingsocialnetworksusingr.com/xucinet)
Owner
- Name: Alejandro Espinosa-Rada
- Login: anespinosa
- Kind: user
- Company: ETH Zürich
- Website: https://sn.ethz.ch
- Twitter: aespinosarada
- Repositories: 2
- Profile: https://github.com/anespinosa
Alejandro Espinosa-Rada is a Postdoctoral Researcher at the Social Networks Lab in ETH Zürich.
CodeMeta (codemeta.json)
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"identifier": "netmem",
"description": "Measures to describe and manipulate networks using matrices. ",
"name": "netmem: Social Network Measures using Matrices",
"codeRepository": "https://github.com/anespinosa/netmem",
"issueTracker": "https://github.com/anespinosa/netmem/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "1.0.3",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.1.2 (2021-11-01)",
"author": [
{
"@type": "Person",
"givenName": "Alejandro",
"familyName": "Espinosa-Rada",
"email": "alejandro.espinosa@gess.ethz.ch",
"@id": "https://orcid.org/0000-0003-4177-1912"
}
],
"maintainer": [
{
"@type": "Person",
"givenName": "Alejandro",
"familyName": "Espinosa-Rada",
"email": "alejandro.espinosa@gess.ethz.ch",
"@id": "https://orcid.org/0000-0003-4177-1912"
}
],
"softwareSuggestions": [
{
"@type": "SoftwareApplication",
"identifier": "knitr",
"name": "knitr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=knitr"
},
{
"@type": "SoftwareApplication",
"identifier": "rmarkdown",
"name": "rmarkdown",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rmarkdown"
},
{
"@type": "SoftwareApplication",
"identifier": "covr",
"name": "covr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=covr"
},
{
"@type": "SoftwareApplication",
"identifier": "testthat",
"name": "testthat",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=testthat"
},
{
"@type": "SoftwareApplication",
"identifier": "usethis",
"name": "usethis",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=usethis"
},
{
"@type": "SoftwareApplication",
"identifier": "styler",
"name": "styler",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=styler"
}
],
"softwareRequirements": {
"1": {
"@type": "SoftwareApplication",
"identifier": "R",
"name": "R",
"version": ">= 4.0.0"
},
"2": {
"@type": "SoftwareApplication",
"identifier": "igraph",
"name": "igraph",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=igraph"
},
"3": {
"@type": "SoftwareApplication",
"identifier": "Matrix",
"name": "Matrix",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=Matrix"
},
"4": {
"@type": "SoftwareApplication",
"identifier": "stats",
"name": "stats"
},
"SystemRequirements": null
},
"fileSize": "1720.523KB",
"readme": "https://github.com/anespinosa/netmem/blob/master/README.md",
"contIntegration": [
"https://github.com/anespinosa/netmem/actions",
"https://ci.appveyor.com/project/anespinosa/netmem",
"https://codecov.io/gh/anespinosa/netmem?branch=master"
],
"developmentStatus": "https://www.tidyverse.org/lifecycle/#experimental",
"keywords": [
"social-network-analysis",
"sociology",
"matrices",
"network-science",
"multilevel-networks",
"network-analysis",
"r",
"r-package",
"rstats",
"multilayer-networks"
]
}
GitHub Events
Total
- Issues event: 2
- Watch event: 2
- Issue comment event: 1
- Push event: 9
Last Year
- Issues event: 2
- Watch event: 2
- Issue comment event: 1
- Push event: 9
Dependencies
DESCRIPTION
cran
- R >= 4.0.0 depends
- Matrix * imports
- igraph * imports
- stats * imports
- covr * suggests
- knitr * suggests
- rmarkdown * suggests
- styler * suggests
- testthat * suggests
- usethis * suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/check-r-package v1 composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v1 composite
- r-lib/actions/setup-r-dependencies v1 composite
.github/workflows/lint.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/setup-r v1 composite
- r-lib/actions/setup-r-dependencies v1 composite
.github/workflows/check-standard.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/pkgdown.yaml
actions
- JamesIves/github-pages-deploy-action v4.4.1 composite
- actions/checkout v3 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