Skip to content

Commit d2b4feb

Browse files
gvegayonaoliveram
andauthored
Applying refactoring (#3)
* adding the project repo link * updating gitignore * updating README, with link to past versions * updating index, with link to past versions * updating shorter version of 2-read * shorter version of 3-netdiffuser, focusing in visualization * visualization script * shorter version of 4-stats * updated version of 5-sim * second part of simulation, regarding multi and dis * all up to date * updating _quarto-yml * fixing [Visualization](3-visualization.qmd) * adding title * intro files * changing dates * adjusting Appendix * checking for consistency * adding setting chunk * adding getstarted as misc * reading kfamily dataset * minor changes to visualization * adding intro to netdiffuseR as misc * minor changes to read * moving -Network Threshold- equation to sims * minor changes for consistency * adding netdiffuser intro to misc * adding classic diffnet analysis to read.qmd * adapting visualization methods to kfamily and removing contents.qmd * adapting to kfamily and clarifying disadoption examples * enhancing random_dis function * everithing up to date * Reorganizing workshop * changing authors structure * adding text and more examples to the Appendix * changing to village#2 * adapting stats to kfamily * back to village 21 * back to village 21 * diffreg analysis with kfam data * polishing stats lecture * polishing stats lecture 2 * modifiying solution scripts * adding sim-solutions * minor changes * fixing reference to sim-solutions-1 * changing names for consistency * updating solution script * refining exercises * Adding dev container --------- Co-authored-by: aoliveram <anibal.olivera.m@gmail.com>
1 parent ab66bcd commit d2b4feb

31 files changed

Lines changed: 2014 additions & 1275 deletions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"r.plot.useHttpgd": true,
3+
"r.alwaysUseActiveTerminal": true
4+
}

.devcontainer/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM rocker/tidyverse:4.4.0
2+
3+
# RUN \
4+
# echo 'options(repos=c(CRAN="https://packagemanager.posit.co/cran/__linux__/bookworm/latest"))' >> ~/.Rprofile && \
5+
# Rscript --vanilla -e 'getOption("repos")'
6+
7+
# Adding R packages
8+
RUN install2.r Rcpp sna network networkDynamic Matrix MASS MatchIt SparseM igraph \
9+
viridisLite covr testthat knitr rmarkdown ape RSiena survival RcppArmadillo
10+
11+
RUN install2.r languageserver httpgd
12+
13+
RUN apt-get update && apt-get install --no-install-recommends -y valgrind gdb \
14+
libglpk-dev
15+
16+
RUN Rscript --vanilla -e \
17+
'remotes::install_github("USCCANA/netdiffuseR@gvegayon-preparing-release-connections")'
18+
19+
CMD ["bash"]

.devcontainer/devcontainer.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
3+
{
4+
"name": "epiworldR",
5+
"build": {
6+
"dockerfile": "Dockerfile"
7+
},
8+
"customizations": {
9+
"vscode": {
10+
"extensions": [
11+
"reditorsupport.r",
12+
"rdebugger.r-debugger",
13+
"quarto.quarto",
14+
"tianyishi.rmarkdown"
15+
]
16+
}
17+
},
18+
"mounts": [
19+
// Mount the .vscode configuration into the container
20+
"source=${localWorkspaceFolder}/.devcontainer/.vscode,target=/workspaces/${localWorkspaceFolderBasename}/.vscode,type=bind,consistency=cached"
21+
]
22+
// Features to add to the dev container. More info: https://containers.dev/features.
23+
// "features": {},
24+
25+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
26+
// "forwardPorts": [],
27+
28+
// Use 'postCreateCommand' to run commands after the container is created.
29+
// "postCreateCommand": "gcc -v",
30+
31+
// Configure tool-specific properties.
32+
// "customizations": {},
33+
34+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
35+
// "remoteUser": "root"
36+
}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
*_cache/
22
*_files/
33
.Rproj.user
4+
.Rhistory
5+
.DS_Store
6+
*/.DS_Store
7+
**/.DS_Store
48

59
/.quarto/
610
docs/
File renamed without changes.

0-netdiffuser.qmd

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: "Introduction to the package"
3+
author: "George G. Vega Yon and Aníbal Olivera M."
4+
date: "2025-06-24"
5+
date-modified: "2025-06-24"
6+
---
7+
8+
```{r setup, echo=FALSE, message=FALSE, warning=FALSE}
9+
library(netdiffuseR)
10+
knitr::opts_chunk$set(comment = "#")
11+
```
12+
13+
14+
- **Network thresholds** (Valente, 1995; 1996), $\tau$, are defined as the required proportion or number of neighbors that leads you to adopt a particular behavior (innovation), $a=1$. In (very) general terms\pause
15+
16+
$$
17+
a_i = \left\{\begin{array}{ll}
18+
1 &\mbox{if } \tau_i\leq E_i \\
19+
0 & \mbox{Otherwise}
20+
\end{array}\right. \qquad
21+
E_i \equiv \frac{\sum_{j\neq i}\mathbf{X}_{ij}a_j}{\sum_{j\neq i}\mathbf{X}_{ij}}
22+
$$
23+
24+
Where $E_i$ is i's exposure to the innovation and $\mathbf{X}$ is the adjacency matrix (the network).
25+
26+
- This can be generalized and extended to include covariates and other network weighting schemes (that's what __netdiffuseR__ is all about).
27+
28+
# netdiffuseR
29+
30+
- **netdiffuseR** is an R package that:
31+
32+
- Allow to generalize the network threshold concept to include covariates and other network weighting schemes.
33+
34+
- Is designed for Visualizing, Analyzing and Simulating network diffusion data (in general).
35+
36+
- Depends on some pretty popular packages:
37+
38+
- _RcppArmadillo_: So it's fast,
39+
- _Matrix_: So it's big,
40+
- _statnet_ and _igraph_: So it's not from scratch
41+
42+
- Can handle big graphs, e.g., an adjacency matrix with more than 4 billion elements (PR for RcppArmadillo).
43+
44+
- Already on CRAN with +48,000 downloads since its first version, Feb 2016.
45+
46+
<!-- Can simulate Threshold Diffusion Models (also know as Complex Contagion) in different scenarios, including multiple simulations at once, multi-diffusion settings, and disadoption parameters. -->
47+
48+
- **Datasets**
49+
50+
- **netdiffuseR** has the three classic Diffusion Network Datasets, both as surveys:
51+
52+
- `medInnovations` Doctors and the innovation of Tetracycline (1955),
53+
- `brfarmers` Brazilian farmers and the innovation of Hybrid Corn Seed (1966),
54+
- `kfamily` Korean women and Family Planning methods (1973),
55+
56+
and as `diffnet` objects:
57+
58+
- `medInnovationsDiffNet` Doctors and the innovation of Tetracycline (1955),
59+
- `brfarmersDiffNet` Brazilian farmers and the innovation of Hybrid Corn Seed (1966),
60+
- `kfamilyDiffNet` Korean women and Family Planning methods (1973)
61+
62+
```{r printing}
63+
brfarmersDiffNet
64+
medInnovationsDiffNet
65+
kfamilyDiffNet
66+
```

0 commit comments

Comments
 (0)