-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbinary_demo.Rmd
More file actions
59 lines (41 loc) · 1021 Bytes
/
binary_demo.Rmd
File metadata and controls
59 lines (41 loc) · 1021 Bytes
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
---
title: "Modeling a binary network outcome"
author: "Peter Hoff"
date: "`r substring(Sys.time(),1,10)`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Modeling a binary network outcome}
%\VignetteEngine{knitr::rmarkdown}
\usepackage[utf8]{inputenc}
---
Load the library:
```{r}
library(amen)
```
Set up the data:
```{r}
data(lazegalaw)
Y<-lazegalaw$Y[,,2]
Xn<-lazegalaw$X[,c(2,4,5,6)]
Xd<-lazegalaw$Y[,,-2]
Xd<-array( c(Xd,outer(Xn[,4],Xn[,4],"==")),dim=dim(Xd)+c(0,0,1))
dimnames(Xd)[[3]]<-c("advice","cowork","samepractice")
dimnames(Xd)[[3]]
dimnames(Xn)[[2]]
```
plot the network with "practice" denoted by plotting color:
```{r,results='hide',message=FALSE}
netplot(lazegalaw$Y[,,2],ncol=Xn[,4])
```
```{r,fig.keep='last',results='hide',cache=TRUE}
fitSRRM<-ame(Y, Xd=Xd, Xr=Xn, Xc=Xn, family="bin")
```
```{r}
summary(fitSRRM)
```
```{r,fig.keep='last',results='hide',cache=TRUE}
fitAME<-ame(Y, Xd=Xd, Xr=Xn, Xc=Xn, R=3, family="bin")
```
```{r}
summary(fitAME)
```