{"id":20396834,"url":"https://github.com/usccana/netdiffuser","last_synced_at":"2025-04-04T11:16:06.560Z","repository":{"id":24794221,"uuid":"28208077","full_name":"USCCANA/netdiffuseR","owner":"USCCANA","description":"netdiffuseR: Analysis of Diffusion and Contagion Processes on Networks","archived":false,"fork":false,"pushed_at":"2025-02-03T21:39:53.000Z","size":104875,"stargazers_count":88,"open_issues_count":28,"forks_count":21,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-04T11:15:42.718Z","etag":null,"topics":["contagion","diffusion-network","network-analysis","network-visualization","r"],"latest_commit_sha":null,"homepage":"https://USCCANA.github.io/netdiffuseR","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/USCCANA.png","metadata":{"files":{"readme":"README.Rmd","changelog":"ChangeLog","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-12-19T00:44:59.000Z","updated_at":"2025-01-22T17:14:15.000Z","dependencies_parsed_at":"2023-01-14T01:37:35.184Z","dependency_job_id":"6aea6e51-02c5-4a74-b3ab-3693be82630b","html_url":"https://github.com/USCCANA/netdiffuseR","commit_stats":{"total_commits":373,"total_committers":5,"mean_commits":74.6,"dds":"0.034852546916890104","last_synced_commit":"7c5c9a7d4a8120491bfd44d6e307bdb5b66c18ae"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/USCCANA%2FnetdiffuseR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/USCCANA%2FnetdiffuseR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/USCCANA%2FnetdiffuseR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/USCCANA%2FnetdiffuseR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/USCCANA","download_url":"https://codeload.github.com/USCCANA/netdiffuseR/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166169,"owners_count":20894654,"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":["contagion","diffusion-network","network-analysis","network-visualization","r"],"created_at":"2024-11-15T04:09:49.544Z","updated_at":"2025-04-04T11:16:06.544Z","avatar_url":"https://github.com/USCCANA.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput:\n  github_document:\n    html_preview: false\n---\n\n[![R-CMD-check](https://github.com/USCCANA/netdiffuseR/actions/workflows/r.yml/badge.svg)](https://github.com/USCCANA/netdiffuseR/actions/workflows/r.yml)\n[![codecov.io](https://codecov.io/github/USCCANA/netdiffuseR/coverage.svg?branch=master)](https://app.codecov.io/github/USCCANA/netdiffuseR?branch=master)\n[![](https://cranlogs.r-pkg.org/badges/netdiffuseR)](https://cran.r-project.org/package=netdiffuseR)\n[![CRAN\\_Status\\_Badge](https://www.r-pkg.org/badges/version/netdiffuseR)](https://cran.r-project.org/package=netdiffuseR)\n[![](https://cranlogs.r-pkg.org/badges/grand-total/netdiffuseR)](https://cran.r-project.org/package=netdiffuseR)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1039317.svg)](https://doi.org/10.5281/zenodo.1039317)\n[![Dependencies](https://tinyverse.netlify.com/badge/netdiffuseR)](https://cran.r-project.org/package=netdiffuseR)\n[![USC's Department of Preventive Medicine](https://raw.githubusercontent.com/USCbiostats/badges/master/tommy-uscprevmed-badge.svg)](https://pphs.usc.edu/center/cana/)\n\n\u003ch1\u003enetdiffuseR: Analysis of Diffusion and Contagion Processes on Networks\u003cimg src=\"man/figures/netdiffuser-logo.svg\" style=\"max-width:200px;width:50%;\" align=\"right\"\u003e\u003c/h1\u003e\n\nThis package contains functions useful for analyzing network data for diffusion of innovations applications.\n\nThe package was developed as part of the paper Thomas W. Valente, Stephanie R.\nDyal, Kar-Hai Chu, Heather Wipfli, Kayo Fujimoto, *Diffusion of innovations theory applied to global tobacco control treaty ratification*,\nSocial Science \u0026 Medicine, Volume 145, November 2015, Pages 89-97, ISSN 0277-9536\n(available [here](https://www.sciencedirect.com/science/article/pii/S027795361530143X))\n\nFrom the description:\n\n\u003e Empirical statistical analysis, visualization and simulation\n    of diffusion and contagion processes on networks. The package implements\n    algorithms for calculating network diffusion statistics such as transmission\n    rate, hazard rates, exposure models, network threshold levels, infectiousness\n    (contagion), and susceptibility. The package is inspired by work published in\n    Valente, et al., (2015); Valente (1995), Myers (2000), Iyengar and others\n    (2011), Burt (1987); among\n    others.\n  \n__Acknowledgements__:  netdiffuseR was created with the support of grant R01 CA157577 from the National Cancer Institute/National Institutes of Health. \n\n```{r, comment = \"\"}\ncitation(package=\"netdiffuseR\")\n```\n\n## News\n\nChangelog can be view [here](NEWS.md).\n\n* [2016-06-02] A video of the __netdiffuseR__ workshop at SUNBELT 2016 is now online on [youtube](https://www.youtube.com/playlist?list=PLT-GgRN1lFI4coHDqkRJm3flDw9e1gg2P), and the workshop materials can be found [here](https://github.com/USCCANA/netdiffuser-sunbelt2016/)\n* [2016-04-11] __netdiffuseR__ will be on [useR! 2016](https://user2016.r-project.org/) on as a presentation and on [IC2S2 2016](https://www.kellogg.northwestern.edu/news-events/conference/ic2s2/2016.aspx) in the posters session.\n* [2016-03-16] Next CRAN release scheduled for April 11th 2016 (after the workshop).\n* [2016-02-18] __netdiffuseR__ vers 1.16.2 is now on CRAN!\n\n## Installation\n\n### CRAN version\n\nTo get the CRAN (stable) version of the package, simple type\n\n```r\ninstall.packages(\"netdiffuseR\")\n```\n\n### Bleeding edge version\n\nIf you want the latest (unstable) version of __netdiffuseR__, using the `devtools` package, you can install `netdiffuseR` dev version as follows\n\n```r\ndevtools::install_github('USCCANA/netdiffuseR', build_vignettes = TRUE)\n```\n\nYou can skip building vignettes by setting `build_vignettes = FALSE` (so it is not required).\n\nFor the case of OSX users, there seems to be a problem when installing packages \ndepending on `Rcpp`. This issue, developed [here](https://github.com/USCCANA/netdiffuseR/issues/3),\ncan be solved by open the terminal and typing the following\n\n```sh\ncurl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2\nsudo tar fvxz gfortran-4.8.2-darwin13.tar.bz2 -C /\n```\n\nbefore installing the package through `devtools`.\n\n### Binary versions\n\nFor the case of windows and mac users, they can find binary versions of the package [here](https://github.com/USCCANA/netdiffuseR/releases), netdiffuseR_1...zip, and netdiffuseR_1...tgz respectively. They can install this directly as follows (using the 1.16.3.29 version):\n\n\n1.  Install dependencies from CRAN\n    ``` r\n    \u003e install.packages(c(\"igraph\", \"Matrix\", \"SparseM\", \"RcppArmadillo\", \"sna\"), dependencies=TRUE)\n    ```\n    \n2.  Download the binary version and install it as follows:\n\n    ``` r\n    \u003e install.packages(\"netdiffuseR_1.16.3.29.zip\", repos=NULL)\n    ```\n    \n    For windows users, and for Mac users:\n    \n    ``` r\n    \u003e install.packages(\"netdiffuseR_1.16.3.29.tgz\", repos=NULL)\n    ```\n\n## Tutorials\n\nSince starting netdiffuseR, we have done a couple of workshops at Sunbelt and NASN. Here are the repositories:\n\n* Sunbelt 2018: https://usccana.github.io/netdiffuser-sunbelt2018/ ([source code](https://github.com/USCCANA/netdiffuser-sunbelt2018))\n* NASN 2017: https://usccana.github.io/netdiffuser-nasn2017/ ([source code](https://github.com/USCCANA/netdiffuser-nasn2017))\n* Sunbelt 2016: https://github.com/USCCANA/netdiffuser-sunbelt2016\n\n## Presentations\n\n* ic2s2 2016 Evanston, IL: https://github.com/USCCANA/netdiffuser-ic2s22016 (poster)\n* useR! 2016 Stanford, CA: https://github.com/USCCANA/netdiffuser-user2016 (slides)\n* useR! 2016: https://github.com/USCCANA/netdiffuser-user2016\n\n## Examples\n\nThis example has been taken from the package's vignettes:\n\n\n```{r loading}\nlibrary(netdiffuseR)\n```\n\n### Infectiousness and Susceptibility\n\n```{r plot_infectsuscept}\n# Generating a random graph\nset.seed(1234)\nn \u003c- 100\nnper \u003c- 20\ngraph \u003c- rgraph_er(n, nper, .5)\ntoa \u003c- sample(c(1:(1+nper-1), NA), n, TRUE)\nhead(toa)\n\n# Creating a diffnet object\ndiffnet \u003c- as_diffnet(graph, toa)\ndiffnet\nsummary(diffnet)\n\n# Visualizing distribution of suscep/infect\nout \u003c- plot_infectsuscep(diffnet, bins = 20,K=5, logscale = FALSE, h=.01)\nout \u003c- plot_infectsuscep(diffnet, bins = 20,K=5, logscale = TRUE,\n                         exclude.zeros = TRUE, h=1)\n```\n\n### Threshold\n\n```{r BoringThreshold, plot_threshold, fig.height=7}\n# Generating a random graph\nset.seed(123)\ndiffnet \u003c- rdiffnet(500, 20,\n                    seed.nodes = \"random\",\n                    rgraph.args = list(m=3),\n                    threshold.dist = function(x) runif(1, .3, .7))\ndiffnet\n\n# Threshold with fixed vertex size\nplot_threshold(diffnet)\n```\n\nUsing more features\n\n```{r NiceThreshold, cache=FALSE}\ndata(\"medInnovationsDiffNet\")\nset.seed(131)\nplot_threshold(\n  medInnovationsDiffNet,\n  vertex.color     = viridisLite::inferno(4)[medInnovationsDiffNet[[\"city\"]]],\n  vertex.sides     = medInnovationsDiffNet[[\"city\"]] + 2,\n  sub = \"Note: Vertices' sizes and shapes given by degree and city respectively\",\n  jitter.factor = c(1,1), jitter.amount = c(.25,.025)\n)\n```\n\n\n### Adoption rate\n\n```{r Adopters}\nplot_adopters(diffnet)\n```\n\n\n### Hazard rate\n\n```{r Hazard}\nhazard_rate(diffnet)\n```\n\n\n### Diffusion process\n\n```{r plot_diffnet, fig.width=7, fig.height=4, message=FALSE}\nplot_diffnet(medInnovationsDiffNet, slices=c(1,9,8))\n```\n\n```{r plot_diffnet2}\ndiffnet.toa(brfarmersDiffNet)[brfarmersDiffNet$toa \u003e= 1965] \u003c- NA\nplot_diffnet2(brfarmersDiffNet, vertex.size = \"indegree\")\n```\n\n```{r plot_diffnet2 with map, }\nset.seed(1231)\n\n# Random scale-free diffusion network\nx \u003c- rdiffnet(1000, 4, seed.graph=\"scale-free\", seed.p.adopt = .025,\n                           rewire = FALSE, seed.nodes = \"central\",\n                           rgraph.arg=list(self=FALSE, m=4),\n                           threshold.dist = function(id) runif(1,.2,.4))\n\n# Diffusion map (no random toa)\ndm0 \u003c- diffusionMap(x, kde2d.args=list(n=150, h=1), layout=igraph::layout_with_fr)\n\n# Random\ndiffnet.toa(x) \u003c- sample(x$toa, size = nnodes(x))\n\n# Diffusion map (random toa)\ndm1 \u003c- diffusionMap(x, layout = dm0$coords, kde2d.args=list(n=150, h=.5))\n\noldpar \u003c- par(no.readonly = TRUE)\ncol \u003c- viridisLite::plasma(100)\npar(mfrow=c(1,2), oma=c(1,0,0,0), cex=.8)\nimage(dm0, col=col, main=\"Non-random Times of Adoption\\nAdoption from the core.\")\nimage(dm1, col=col, main=\"Random Times of Adoption\")\npar(mfrow=c(1,1))\nmtext(\"Both networks have the same distribution on times of adoption\", 1,\n      outer = TRUE)\npar(oldpar)\n```\n\n### Adopters classification\n\n```{r mosaic}\nout \u003c- classify(kfamilyDiffNet, include_censored = TRUE)\nftable(out)\n\n# Plotting \noldpar \u003c- par(no.readonly = TRUE)\npar(xpd=TRUE)\nplot(out, color=viridisLite::inferno(5), las = 2, xlab=\"Time of Adoption\",\n     ylab=\"Threshold\", main=\"\")\n\n# Adding key\nlegend(\"bottom\", legend = levels(out$thr), fill=viridisLite::inferno(5), horiz = TRUE,\n       cex=.6, bty=\"n\", inset=c(0,-.1))\npar(oldpar)\n```\n\n\n### Session info\n\n```{r Showing session info}\nsessionInfo()\n```\n\n\n## To-do list\n\n- Import/Export functions for interfacing other package's clases, in particular: `statnet` set (specially the packages `networkDynamic` and `ndtv`), ~~`igraph`~~ and `Rsiena`.\n- Populate the tests folder.\n- ~~Use spells? (`select_egoalter` would use this)~~\n- ~~Classify individuals by adoption category using early adopters, adopters, and laggards, and by threshold using very low, low, high and very high threshold (Valente 95' p. 94).~~\n- ~~Double check all functions using adjacency matrix values.~~\n- ~~Remove dimnames from matrices and vectors. It is more efficient to use the ones stored in meta instead.~~\n- Implement the Bass model\n- ~~Include function to import survey data (as shown on the vignettes)~~\n- Exposure based on Mahalanobis distances and also Roger Leenders on weighting exposure (internal note).\n- (2016-03-30): use `xspline` for drawing polygons \u0026 edges.\n- ~~(2016-04-04): Add more options to `exposure`, namely, `self` (so removes diagonal or not!).~~\n- (2016-04-19): animal behaviorists.\n- (2016-10-18): Review language throughout the manual (more than innovation).\n- (2016-10-18): Evaluate and eventually use a standard graph format (`network` for instance?).\n- (2016-10-18): Standarize graph plot methods (choose either statnet/igraph/own)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusccana%2Fnetdiffuser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fusccana%2Fnetdiffuser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusccana%2Fnetdiffuser/lists"}