/
README.Rmd
146 lines (106 loc) · 3.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
message = FALSE,
warning = FALSE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# ergmito: Estimation of Little 'ERGMs' using exact likelihood
[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/ergmito)](https://cran.r-project.org/package=ergmito)
[![Travis build status](https://travis-ci.org/muriteams/ergmito.svg?branch=master)](https://travis-ci.org/muriteams/ergmito)
[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/nl1irakr2g6y6w03?svg=true)](https://ci.appveyor.com/project/gvegayon/ergmito)
[![codecov](https://codecov.io/gh/muriteams/ergmito/branch/master/graph/badge.svg)](https://codecov.io/gh/muriteams/ergmito)
This R package, which has been developed on top of the amazing work that the
[Statnet](https://github.com/statnet) team has done, implements estimation and
simulation methods for Exponential Random Graph Models of small networks, in
particular, less than 7 nodes. In the case of small networks, the calculation
of the likelihood of ERGMs becomes computationally feasible, which allows us
avoiding approximations and do exact calculation, ultimately obtaining MLEs
directly.
## Support
This material is based upon work support by, or in part by, the U.S.
Army Research Laboratory and the U.S. Army Research Office under
grant number W911NF-15-1-0577
Computation for the work described in this paper was supported by
the University of Southern California's Center for High-Performance
Computing (hpcc.usc.edu).
## Installation
The development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("muriteams/ergmito")
```
## Example
An example from the manual
## When `ergm` is not enough
```{r net1}
library(ergmito)
library(sna)
# Generating a small graph
set.seed(12)
n <- 4
net <- sna::rgraph(n, tprob = .7)
gplot(net)
```
```{r comparing-w-ergm}
model <- net ~ edges + mutual + ctriad
library(ergm)
ans_ergmito <- ergmito(model)
ans_ergm <- ergm(model)
# The ergmito should have a larger value when computing exact loglikelihood
ergm.exact(ans_ergmito$coef, model) >
ergm.exact(ans_ergm$coef, model)
summary(ans_ergmito)
summary(ans_ergm)
```
Checking convergence diagnostics
```{r convergence-diag}
plot(ans_ergmito)
```
## Do we get the same?
```{r net2}
# Generating a small graph
set.seed(12123)
n <- 4
net <- sna::rgraph(n, tprob = .3)
gplot(net)
```
```{r}
model <- net ~ edges + mutual
library(ergm)
ans_ergmito <- ergmito(model)
ans_ergm <- ergm(model, control = control.ergm(
MCMC.effectiveSize = 4000,
seed = 444)
)
# The ergmito should have a larger value
ergm.exact(ans_ergmito$coef, model) > ergm.exact(ans_ergm$coef, model)
summary(ans_ergmito)
summary(ans_ergm)
```
## Estimating data with known parameters
The following example shows the estimation of a dataset that is included in the package,
`fivenets`. This set of five networks was generated using the `new_rergmito` function
which allows creating a function to draw random ERGMs with a fixed set of parameters,
in this case, `edges = -4` and `nodeicov("age") = .2`
```{r fivenets}
data(fivenets)
model1 <- ergmito(fivenets ~ edges + nodeicov("age"))
summary(model1) # This data has know parameters equal to -4.0 and 0.2
```
# Similarity indices
https://cran.r-project.org/web/packages/proxy/proxy.pdf
A Survey of Binary Similarity and Distance Measures
Seung-Seok Choi, Sung-Hyuk Cha, Charles C. Tappert
Department of Computer Science, Pace University
New York, US
# Contributing
Please note that the 'ergmito' project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.