-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTutorialDattilo.qmd
More file actions
79 lines (61 loc) · 2.04 KB
/
TutorialDattilo.qmd
File metadata and controls
79 lines (61 loc) · 2.04 KB
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
75
76
77
78
79
---
title: "Tutorial on Multipartite block models"
subtitle: "April 2024"
author: "Econet group"
date: "04/24/2024"
output:
rmarkdown::html_vignette:
toc: true
toc_depth: 4
bibliography: references.bib
link-citations: true
editor:
markdown:
wrap: sentence
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
# 0.Requirements
This tutorial illustrates the use of block models for the analysis of (ecological) multipartite network.
Is is mainly based on a [vignette](https://grosssbm.github.io/sbm/articles/Multipartite_EcologicalNetwork.html) of the package `sbm` .
The package is on the CRAN. Its development version is on [Github](https://github.com/GrossSBM/sbm). It as been installed earlier during the week.
```{r install, message=FALSE, warning=FALSE, eval=FALSE, echo = TRUE}
install.packages("sbm")
```
```{r setup, message=FALSE, warning=FALSE}
library(sbm)
library(ggplot2)
```
# 1. What if I have more than 2 types of nodes?
The sbm package is able to handle multipartite networks, meaning that they involve more that two types of nodes and intra and inter groups connections.
We analyse the data from @Dattilo with the method proposed by @multipartite.
```{r }
data(multipartiteEcologicalNetwork)
Net <- multipartiteEcologicalNetwork
type = "bipartite"
model = "bernoulli"
directed = FALSE
PlantFlovis <- defineSBM(Net$Inc_plant_flovis, model, type, directed, dimLabels = c("Plants",
"Flovis"))
PlantAnt <- defineSBM(Net$Inc_plant_ant, model, type, directed, dimLabels = c("Plants",
"Ants"))
PlantBird <- defineSBM(Net$Inc_plant_bird, model, type, directed, dimLabels = c("Plants",
"Birds"))
plotMyMultipartiteMatrix(list(PlantFlovis, PlantAnt, PlantBird))
```
We can also find block of species
```{r }
data(multipartiteEcologicalNetwork)
estimOptions = list(initBM = FALSE)
listSBM <- list(PlantFlovis, PlantAnt, PlantBird)
myMSBM <- estimateMultipartiteSBM(listSBM, estimOptions)
```
```{r }
plot(myMSBM)
```
These options are not included in the Shiny application yet.
## References