{"id":16703749,"url":"https://github.com/mbojan/netseg","last_synced_at":"2025-03-21T20:32:16.913Z","repository":{"id":56935241,"uuid":"226693752","full_name":"mbojan/netseg","owner":"mbojan","description":"Segregation and homophily measurement in social networks","archived":false,"fork":false,"pushed_at":"2023-07-04T12:05:15.000Z","size":2798,"stargazers_count":16,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-01-25T09:08:05.094Z","etag":null,"topics":["homophily","r","segregation","social-networks"],"latest_commit_sha":null,"homepage":"https://mbojan.github.io/netseg/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mbojan.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-12-08T16:04:57.000Z","updated_at":"2023-05-31T17:39:11.000Z","dependencies_parsed_at":"2024-01-03T05:06:28.528Z","dependency_job_id":"2fa8872f-4e2f-45bd-b2f0-b09b7ef1a0e7","html_url":"https://github.com/mbojan/netseg","commit_stats":{"total_commits":131,"total_committers":2,"mean_commits":65.5,"dds":0.007633587786259555,"last_synced_commit":"a29a84401741827476531d133d9e7c3677e24cfb"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbojan%2Fnetseg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbojan%2Fnetseg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbojan%2Fnetseg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbojan%2Fnetseg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mbojan","download_url":"https://codeload.github.com/mbojan/netseg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244865892,"owners_count":20523423,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["homophily","r","segregation","social-networks"],"created_at":"2024-10-12T19:09:21.118Z","updated_at":"2025-03-21T20:32:16.462Z","avatar_url":"https://github.com/mbojan.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\nbibliography: vignettes/refs.bib\noutput: github_document\neditor_options: \n  chunk_output_type: console\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r setup, 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```{r logo, include = FALSE, eval=FALSE}\nlibrary(hexSticker)\nlibrary(ergm)\nlibrary(magrittr)\nlibrary(tidygraph)\nlibrary(ggraph)\n\nset.seed(666)\nnet \u003c- network.initialize(30, directed=FALSE)\nnet %v% \"a1\" \u003c- sample( rep(1:2, each=15) )\nnet %v% \"a2\" \u003c- sample( rep(1:2, each=15) )\n\nsnet \u003c- simulate(\n  net ~ edges + nodematch(\"a1\") + nodematch(\"a2\"),\n  coef = c(-5, 3, 3)\n)\n\ng \u003c- intergraph::asIgraph(snet) %\u003e%\n  as_tbl_graph()\n\np \u003c- g %\u003e%\n  ggraph(layout=\"stress\") +\n  geom_edge_link(\n    color=\"gray50\",\n    edge_width = 1/4\n    ) +\n  geom_node_point(\n    aes(\n      color=as.character(a1),\n      fill=as.character(a2)\n    ),\n    shape = 21,\n    size=1,\n    stroke = 1\n  ) +\n  scale_fill_brewer(type=\"qual\", palette=\"Set1\") +\n  scale_color_brewer(type=\"qual\", palette=\"Set1\") +\n  theme_graph(\n    base_family = \"sans\"\n  )\n\n\nsticker(\n  p + theme_void() +\n    theme_transparent() +\n    theme(legend.position=\"none\"),\n  p_size=20,\n  p_x = 1,\n  p_y = 1.6,\n  s_x = 1,\n  s_y= 0.9,\n  s_width=1.3,\n  s_height=1,\n  package = \"netseg\",\n  p_color = \"gray50\",\n  h_fill = \"#ffffff\",\n  h_color = \"black\",\n  url = \"https://mbojan.github.io/netseg\",\n  u_size = 4,\n  filename = \"man/figures/logo.png\",\n  dpi = 300\n)\n```\n\n\n\n\n\n# `netseg`: Measures of Network Segregation and Homophily \u003cimg src=\"man/figures/logo.png\" align=\"right\" width=\"20%\" /\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/netseg)](https://CRAN.R-project.org/package=netseg)\n[![rstudio cran mirror downloads](https://cranlogs.r-pkg.org/badges/netseg?color=2ED968)](https://cranlogs.r-pkg.org/)\n[![R-CMD-check](https://github.com/mbojan/netseg/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/mbojan/netseg/actions/workflows/R-CMD-check.yaml)\n\u003c!-- badges: end --\u003e\n\nSegregation is a network-level property such that edges between predefined groups of vertices are relatively less likely. Network homophily is a individual-level tendency to form relations with people who are similar on some attribute (e.g. gender, music taste, social status, etc.). In general homophily leads to segregation, but segregation might arise without homophily. This package implements descriptive indices measuring homophily/segregation. It is a computational companion to @bojanowski-corten-2014.\n\n## Installation\n\nInstall the released version of netseg from [CRAN](https://CRAN.R-project.org/) with:\n\n```r\ninstall.packages(\"netseg\")\n```\n\nor the development version from [GitHub](https://github.com/) with:\n\n```{r install, eval=FALSE}\n# install.packages(\"remotes\")\nremotes::install_github(\"mbojan/netseg\")\n```\n\n\n\n\n\n\n\n## Example\n\nTo illustrate, consider the Classroom network below:\n\n```{r Classroom, dev=\"svg\"}\nlibrary(netseg)\nlibrary(igraph)\n\ndata(\"Classroom\")\n\nplot(\n  Classroom,\n  layout = graphlayouts::layout_with_stress,\n  vertex.color = c(\"pink\", \"lightskyblue\")[match(V(Classroom)$gender, c(\"Girl\", \"Boy\"))],\n  vertex.label = NA,\n  edge.arrow.size = 0.5\n)\nlegend(\n  \"bottomright\",\n  pch = 21,\n  legend = c(\"Boy\", \"Girl\"),\n  pt.cex = 2,\n  pt.bg = c(\"lightskyblue\", \"pink\"),\n  col = \"black\",\n  bty = \"n\"\n)\n```\n\nThe extent of gender segregation in this network can be assessed using one of the indices provided in the package, for example odds ratio of within-group tie (`orwg()`)\n\n```{r Classroom-orwg}\norwg(Classroom, \"gender\")\n```\n\ntells us that same-gender tie odds are `r orwg(Classroom, \"gender\")` times greater than tie odds between genders. \n\nColeman's index [@coleman-1958] assesses the segregation on the group level:\n\n```{r Classroom-coleman}\ncoleman(Classroom, \"gender\")\n```\n\nQualitatively speaking it compares the proportion of same-group neighbors to the proportion of that group in the network as a whole. It is a number between -1 and 1. Value of 0 means these proportions are equal. Value of 1 means that all ties outgoing from a particular group are sent to the members of the same group. Value of -1 is the opposite -- all ties are sent to members of other group(s).\n\n\n## References\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbojan%2Fnetseg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmbojan%2Fnetseg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbojan%2Fnetseg/lists"}