-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
116 lines (83 loc) · 3.04 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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![Travis build status](https://travis-ci.org/muriteams/gnet.svg?branch=master)](https://travis-ci.org/muriteams/gnet)
[![Build status](https://ci.appveyor.com/api/projects/status/0w08vtiu0wul6blj?svg=true)](https://ci.appveyor.com/project/gvegayon/gnet)
# gnet
The goal of gnet is to ...
## Installation
~~You can install the released version of gnet from [CRAN](https://CRAN.R-project.org) with:~~
``` r
devtools::install_github("muriteams/gnet")
```
## 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).
## Example
This is a basic example which shows you how to solve a common problem:
```{r example1, cache=FALSE}
library(ergmito)
library(gnet)
# A random sample of networks
set.seed(12)
nets <- rbernoulli(c(3,3,4,4,4))
# Are the edgecounts random??
fun <- function(g, y) mean(count_stats(g, "edges") - y, na.rm = TRUE)
mytest01 <- struct_test(nets ~ edges + balance, y = runif(5), R=1000, stat=fun)
```
```{r printing}
mytest01
```
```{r hist}
# Looking at the distribution
hist(mytest01$t, breaks=10, col="gray", border="transparent")
abline(v = mytest01$t0, col="steelblue", lwd=2, lty="dashed")
```
Using the fivenets dataset included in `ergmito`. In this example, we show how the model can be use to discover an association between
```{r fivenets}
# Loading the fivents dataset. We actually know that data generating process,
# so we use these paramaters for the model
data(fivenets, package="ergmito")
# We will generate a group level variable that is related to the proportion of
# females in the group
set.seed(52)
y <- count_stats(fivenets ~ nodeocov("female"))
y <- y + rnorm(nnets(fivenets))
# Performing the struct test
f02 <- function(g, y) cor(count_stats(g ~ nodeocov("female")), y, use = "complete.obs")[1]
mytest02 <- struct_test(
fivenets ~ edges + nodematch("female"), y = y, R=3000,
stat = f02
)
mytest02
```
What would have we got if we use a linear regression only?
```{r ols}
# Li
x <- count_stats(fivenets ~ nodeocov("female"))
summary(lm(y ~ x))
```
```{r plot-comparison}
op <- par(mfrow=c(1, 2))
hist(mytest02$t, breaks=50, col="gray", border="transparent", main = "Null distribution of t",
xlab = "Values of t")
abline(v = mytest02$t0, col="steelblue", lwd=2, lty="dashed")
plot(y ~ x, main = "Linear regression", xlab="nodeocov(\"female\")", ylab = "y")
abline(lm(y~x), lty="dashed", lwd=2)
par(op)
```
In this case, the test has higher power than the other 2.