-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
74 lines (57 loc) · 1.94 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "readme_figures/README-"
)
```
# NetworkInference: Inferring Latent Diffusion Networks
![](https://travis-ci.org/desmarais-lab/NetworkInference.svg) ![](http://www.r-pkg.org/badges/version/NetworkInference)
![](http://cranlogs.r-pkg.org/badges/NetworkInference)
![](http://cranlogs.r-pkg.org/badges/grand-total/NetworkInference?color=yellow)
## About
This package provides an R implementation of the netinf algorithm
created by Gomez-Rodriguez, Leskovec, and Krause (see
[here](http://snap.stanford.edu/netinf/) for more information and the original
C++ implementation). Given a set of events that spread between a set of nodes
the algorithm infers the most likely stable diffusion network that is underlying
the diffusion process.
## Installation
The package can be installed from [CRAN](https://CRAN.R-project.org/):
```{r, eval=FALSE}
install.packages("NetworkInference")
```
The latest development version can be installed from
[github](https://github.com/desmarais-lab/NetworkInference):
```{r, eval=FALSE}
#install.packages(devtools)
devtools::install_github('desmarais-lab/NetworkInference')
```
## Quick start guide
To get started, get your data into the `cascades` format required by the `netinf`
function:
```{r, results='hide', message=FALSE}
library(NetworkInference)
# Simulate random cascade data
df <- simulate_rnd_cascades(50, n_node = 20)
# Cast data into `cascades` object
## From long format
cascades <- as_cascade_long(df)
## From wide format
df_matrix <- as.matrix(cascades) ### Create example matrix
cascades <- as_cascade_wide(df_matrix)
```
Then fit the model:
```{r}
result <- netinf(cascades, quiet = TRUE, p_value_cutoff = 0.05)
```
```{r, eval=FALSE}
head(result)
```
```{r, results="asis", echo=FALSE}
pander::pandoc.table(head(result))
```