{"id":38648845,"url":"https://github.com/anespinosa/netmem","last_synced_at":"2026-01-17T09:17:32.973Z","repository":{"id":38821923,"uuid":"259045418","full_name":"anespinosa/netmem","owner":"anespinosa","description":"'netmem: Network Measures using Matrices' is an R Package","archived":false,"fork":false,"pushed_at":"2025-10-17T15:05:48.000Z","size":13330,"stargazers_count":12,"open_issues_count":17,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-18T17:03:06.013Z","etag":null,"topics":["matrices","multilayer-networks","network-analysis","network-science","r","r-package","rstats","sna","social-network","social-network-analysis","sociology"],"latest_commit_sha":null,"homepage":"https://anespinosa.github.io/netmem/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anespinosa.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":"codemeta.json","zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-04-26T14:04:09.000Z","updated_at":"2025-10-17T15:02:15.000Z","dependencies_parsed_at":"2025-03-11T15:27:37.562Z","dependency_job_id":"e457be36-08fc-4b37-a5c4-4ebcb835c4fb","html_url":"https://github.com/anespinosa/netmem","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/anespinosa/netmem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anespinosa%2Fnetmem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anespinosa%2Fnetmem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anespinosa%2Fnetmem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anespinosa%2Fnetmem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anespinosa","download_url":"https://codeload.github.com/anespinosa/netmem/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anespinosa%2Fnetmem/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28505156,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["matrices","multilayer-networks","network-analysis","network-science","r","r-package","rstats","sna","social-network","social-network-analysis","sociology"],"created_at":"2026-01-17T09:17:30.648Z","updated_at":"2026-01-17T09:17:32.926Z","avatar_url":"https://github.com/anespinosa.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# netmem: Network Measures using Matrices \u003cimg src=\"man/figures/logo.png\" align=\"right\" width=\"180px\"/\u003e\n\n\u003c!-- badges: start --\u003e \n[![CRAN status](https://www.r-pkg.org/badges/version/netmem)](https://CRAN.R-project.org/package=netmem)\n[![r-universe status badge](https://anespinosa.r-universe.dev/badges/netmem)](https://anespinosa.r-universe.dev/netmem)\n[![](https://img.shields.io/badge/devel%20version-1.0--3-red.svg)](https://github.com/https://github.com/anespinosa/netmem)\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)\n[![Codecov test coverage](https://codecov.io/gh/anespinosa/netmem/branch/master/graph/badge.svg)](https://codecov.io/gh/anespinosa/netmem?branch=master)\n[![CodeFactor](https://www.codefactor.io/repository/github/anespinosa/netmem/badge)](https://www.codefactor.io/repository/github/anespinosa/netmem)\n[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/anespinosa/netmem?branch=master\u0026svg=true)](https://ci.appveyor.com/project/anespinosa/netmem)\n[![R-CMD-check](https://github.com/anespinosa/netmem/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/anespinosa/netmem/actions/workflows/R-CMD-check.yaml)\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n[![Github All Releases](https://img.shields.io/github/downloads/anespinosa/netmem/total.svg)]()\n\u003c!-- badges: end --\u003e\n\nThe goal of [`netmem`](https://anespinosa.github.io/netmem/) is to make\navailable different measures to analyse and manipulate complex networks using\nmatrices.\n\n```{r, echo=FALSE, message=FALSE, warning=FALSE}\n# Check if the 'devtools' package is installed\nif (!requireNamespace(\"devtools\", quietly = TRUE)) {\n  install.packages(\"devtools\")\n}\n\n# Check if the 'emo' package is installed via devtools\nif (!requireNamespace(\"emo\", quietly = TRUE)) {\n  devtools::install_github(\"hadley/emo\")\n}\n```\n\n`r emo::ji(\"pen\")` Author/mantainer: [Alejandro\nEspinosa-Rada](https://www.aespinosarada.com)\n\n`r emo::ji(\"school\")` [Current: Institute of Sociology, Pontificia Universidad Católica de Chile](https://sociologia.uc.cl)\n\n`r emo::ji(\"school\")` [Before: Social Networks Lab, ETH Zürich](https://sn.ethz.ch)\n\n[![Follow me on Twitter/X](https://img.shields.io/badge/Follow me on\nTwitter-9cf.svg)](https://x.com/aespinosarada)\n\nThe package implements different measures to analyse and manipulate complex\nmultilayer networks, from an ego-centric perspective, considering one-mode\nnetworks, valued ties (i.e. *weighted* or *multiplex*) or with multiple levels.\n\n## Citation\n\n```{r echo=FALSE, results='asis'}\ncitation(package = \"netmem\")\n```\n\n## Functions currently available in [`netmem`](https://anespinosa.github.io/netmem/reference/index.html):\n\nUtilities:\n\n1. `matrix_report()`: Matrix report\n\n2. `matrix_adjlist()`: Transform a matrix into an adjacency list\n\n3. `matrix_projection()`: Unipartite projections\n\n4. `matrix_to_edgelist()`: Transform a square matrix into an edge-list\n\n5. `adj_to_matrix()`: Transform an adjacency list into a matrix\n\n6. `adj_to_incidence()`: Transform an adjacency matrix into a incidence matrix\n\n7. `cumulativeSumMatrices()`: Cumulative sum of matrices\n\n8. `edgelist_to_matrix()`: Transform an edgelist into a matrix\n\n9. `expand_matrix()`: Expand matrix\n\n10. `extract_component()`: Extract components\n\n11. `hypergraph()`: Hypergraphs\n\n12. `perm_matrix()`: Permutation matrix\n\n13. `perm_label()`: Permute labels of a matrix\n\n14. `power_function()`: Power of a matrix\n\n15. `meta_matrix()`: Meta matrix for multilevel networks\n\n16. `minmax_overlap()`: Minimum/maximum overlap\n\n17. `mix_matrix()`: Mixing matrix\n\n18. `simplicial_complexes()`: Simplicial complexes\n\n19. `structural_na()`: Structural missing data\n\n20. `ego_net()`: Ego network\n\n21. `zone_sample()`: Zone-2 sampling from second-mode\n\nEgo and personal networks:\n\n1. `eb_constraint()`: Constraint\n\n2. `ei_index()`: Krackhardt and Stern's E-I index\n\n3. `heterogeneity()`: Blau's and IQV index\n\n4. `redundancy()`: Redundancy measures\n\nPath distances:\n\n1. `bfs_ugraph()`: Breath-first algorithm\n\n2. `compound_relation()`: Relational composition\n\n3. `count_geodesics()`: Count geodesic distances\n\n4. `short_path()`: Shortest path\n\n5. `wlocal_distances()`: Dijikstra's algorithm (one actor)\n\n6. `wall_distances()`: Dijikstra's algorithm (all actors)\n\nSigned networks:\n\n1. `posneg_index()`: Positive-negative centrality\n\n2. `struc_balance()`: Structural balance\n\nStructural measures:\n\n1. `gen_density()`: Generalized density\n\n2. `gen_degree()`: Generalized degree\n\n3. `multilevel_degree()`: Degree centrality for multilevel networks\n\n4. `recip_coef()`: Reciprocity\n\n5. `trans_coef()`: Transitivity\n\n6. `trans_matrix()`: Transitivity matrix\n\n7. `components_id()`: Components\n\n8. `k_core()`: Generalized k-core\n\n9. `dyadic_census()`: Dyad census\n\n10. `multiplex_census()`: Multiplex triad census\n\n11. `mixed_census()`: Multilevel triad and quadrilateral census\n\nCohesive subgroups:\n\n1. `clique_table()`: Clique table\n\n2. `dyad_triad_table()`: Forbidden triad table\n\n3. `percolation_clique()`: Clique percolation\n\n4. `q_analysis()`: Q-analysis\n\n5. `shared_partners()`: Shared partners\n\nSimilarity measures:\n\n1. `bonacich_norm()`: Bonacich normalization\n\n2. `co_occurrence()`: Co‐occurrence\n\n3. `dist_sim_matrix()`: Structural similarities\n\n4. `fractional_approach()`: Fractional approach\n\n5. `jaccard()`: Jaccard similarity\n\nNetwork inference:\n\n1. `kp_reciprocity()`: Reciprocity of Katz and Powell\n\n2. `z_arctest()`: Z test of the number of arcs\n\n3. `triad_uman()`: Triad census analysis assuming U|MAN\n\n4. `ind_rand_matrix()`: Independent random matrix\n\nGeographic information:\n\n1. `dist_geographic()`: Geographical distances\n\n2. `spatial_cor()`: Spatial autocorrelation\n\nData currently available:\n\n1. `FIFAego`: Ego FIFA\n\n2. `FIFAex`: Outside FIFA\n\n3. `FIFAin`: Inside FIFA\n\n4. `krackhardt_friends`: Krackhardt friends\n\n5. `lazega_lawfirm`: Lazega Law Firm\n\nAdditional data in [`classicnets: Classic Data of Social\nNetworks`](https://github.com/anespinosa/classicnets)\n\n-----\n\n# Quick overview of `netmem: Network Measures using Matrices`\n\n-----\n\n## Installation\n\nYou can install the development version from [GitHub](https://github.com/)\nwith:\n\n```{r inst, eval=FALSE}\n### OPTION 1\n# install.packages(\"devtools\")\ndevtools::install_github(\"anespinosa/netmem\")\n\n### OPTION 2\noptions(repos = c(\n  netmem = \"https://anespinosa.r-universe.dev\",\n  CRAN = \"https://cloud.r-project.org\"\n))\ninstall.packages(\"netmem\")\n```\n\n```{r inst2}\nlibrary(netmem)\n```\n\n-----\n\n## Multilevel Networks\n\nConnections between individuals are often embedded in complex structures, which\nshape actors’ expectations, behaviours and outcomes over time. These structures\ncan themselves be interdependent and exist at different levels. Multilevel\nnetworks are a means by which we can represent this complex system by using\nnodes and edges of different types. Check [this\nbook](https://www.springer.com/gp/book/9783319245188) edited by Emmanuel Lazega\nand Tom A.B. Snijders or [this\nbook](https://www.cambridge.org/core/books/multimodal-political-networks/43EE8C192A1B0DCD65B4D9B9A7842128)\nedited by David Knoke, Mario Diani, James Hollway and Dimitris Christopoulos.\n\n\u003cimg src=\"man/figures/multilevel.png\"/\u003e\n\nFor multilevel structures, we tend to collect the data in different matrices\nrepresenting the variation of ties within and between levels. Often, we describe\nthe connection between actors as an adjacency matrix and the relations between\nlevels through incidence matrices. The comfortable combination of these matrices\ninto a common structure would represent the multilevel network that could be\nhighly complex.\n\n### Example\n\n\u003cdiv class=\"alert alert-info\"\u003e Let's assume that we have a multilevel network\nwith two adjacency matrices, one valued matrix and two incidence matrices\nbetween them.\n\n- `A1`: Adjacency Matrix of the level 1\n\n- `B1`: incidence Matrix between level 1 and level 2\n\n- `A2`: Adjacency Matrix of the level 2\n\n- `B2`: incidence Matrix between level 2 and level 3\n\n- `A3`: Valued Matrix of the level 3 \u003c/div\u003e\n\nCreate the data\n\n```{r multilevel_example}\nA1 \u003c- matrix(c(\n  0, 1, 0, 0, 1,\n  1, 0, 0, 1, 1,\n  0, 0, 0, 1, 1,\n  0, 1, 1, 0, 1,\n  1, 1, 1, 1, 0\n), byrow = TRUE, ncol = 5)\n\nB1 \u003c- matrix(c(\n  1, 0, 0,\n  1, 1, 0,\n  0, 1, 0,\n  0, 1, 0,\n  0, 1, 1\n), byrow = TRUE, ncol = 3)\n\nA2 \u003c- matrix(c(\n  0, 1, 1,\n  1, 0, 0,\n  1, 0, 0\n), byrow = TRUE, nrow = 3)\n\nB2 \u003c- matrix(c(\n  1, 1, 0, 0,\n  0, 0, 1, 0,\n  0, 0, 1, 1\n), byrow = TRUE, ncol = 4)\n\nA3 \u003c- matrix(c(\n  0, 1, 3, 1,\n  1, 0, 0, 0,\n  3, 0, 0, 5,\n  1, 0, 5, 0\n), byrow = TRUE, ncol = 4)\n```\n\nWe will start with a report of the matrices:\n\n```{r matrix_report}\nmatrix_report(A1)\nmatrix_report(B1)\nmatrix_report(A2)\nmatrix_report(B2)\nmatrix_report(A3)\n```\n\nWhat is the density of some of the matrices?\n\n```{r multilevel_example2}\nmatrices \u003c- list(A1, B1, A2, B2)\ngen_density(matrices, multilayer = TRUE)\n```\n\nHow about the degree centrality of the entire structure?\n\n```{r multil, warning=FALSE}\nmultilevel_degree(A1, B1, A2, B2, complete = TRUE)\n```\n\nBesides, we can perform a *k*-core analysis of one of the levels using the\ninformation of an incidence matrix\n\n```{r multil2, warning=FALSE}\nk_core(A1, B1, multilevel = TRUE)\n```\n\nThis package also allows performing complex census for multilevel networks.\n\n```{r multil3}\nmixed_census(A2, t(B1), B2, quad = TRUE)\n```\n\n-----\n\n### Ego measures\n\nWhen we are interested in one particular actor, we could perform different\nnetwork measures. For example, actor `e` has connections with all the other\nactors in the network. Therefore, we could estimate some of Ronald Burt's\nmeasures.\n\n```{r ego}\n# First we will assign names to the matrix\nrownames(A1) \u003c- letters[1:nrow(A1)]\ncolnames(A1) \u003c- letters[1:ncol(A1)]\n\neb_constraint(A1, ego = \"e\")\nredundancy(A1, ego = \"e\")\n```\n\nAlso, sometimes we might want to subset a group of actors surrounding an ego.\n\n```{r ego2}\nego_net(A1, ego = \"e\")\n```\n\n-----\n\n### One-mode network\n\nThis package expand some measures for one-mode networks, such as the generalized\ndegree centrality. Suppose we consider a valued matrix `A3`. If `alpha=0` then\nit would only count the direct connections. But, adding the tuning parameter\n`alpha=0.5` would determine the relative importance of the number of ties\ncompared to tie weights.\n\n```{r onem}\ngen_degree(A3, digraph = FALSE, weighted = TRUE)\n```\n\nAlso, we could conduct some exploratory analysis using the normalized degree of\nan incidence matrix.\n\n```{r onem2}\ngen_degree(B1, bipartite = TRUE, normalized = TRUE)\n```\n \nThis package also implements some analysis of dyads.\n\n```{r onem3}\n# dyad census\ndyadic_census(A1)\n\n# Katz and Powell reciprocity\nkp_reciprocity(A1)\n\n# Z test of the number of arcs\nz_arctest(A1)\n```\n\nWe can also check the triad census assuming conditional uniform distribution\nconsidering different types of dyads **(U|MAN)**\n\n```{r onem4}\ntriad_uman(A1)\n```\n \n-----\n\n### Code of conduct\n\nPlease note that this project is released with a [Contributor Code of\nConduct](https://anespinosa.github.io/netmem/CODE_OF_CONDUCT.html). By\nparticipating in this project you agree to abide by its terms.\n\n-----\n\n### To-do list\n\n```{r todo1}\n# library(todor)\n# todor::todor_package(c(\"TODO\", \"FIXME\"))\n```\n\n-----\n\n### Other related R packages\n\n- [`{bipartite}`](https://github.com/biometry/bipartite)\n\n- [`{migraph}`](https://github.com/snlab-ch/migraph)\n\n- [`{multinet}`](https://CRAN.R-project.org/package=multinet)\n\n- [`{muxViz}`](https://github.com/manlius/muxViz)\n\n- [`{tnet}`](https://toreopsahl.com/tnet/)\n\n- [`{xUCINET}`](https://www.analyzingsocialnetworksusingr.com/xucinet)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanespinosa%2Fnetmem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanespinosa%2Fnetmem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanespinosa%2Fnetmem/lists"}