程序代写代做代考 —


title: “Example 7”
author: “sheng huo”
date: “5/11/2017”
output: html_document

“`{r setup, include=FALSE}
library(knitr)
setwd(“C:/Users/NOAH/Desktop/CSC 495/week7/ex7/ex7”)
read_chunk(“example07.R”)
knitr::opts_chunk$set(echo = TRUE)
“`

## QAP tests

In this example, we work with the second Lord of the Rings network.

### Step 1: Load the necessary libraries

Note that SAND must come after network.

“`{r C1, results=”hide”, warning=FALSE, message=FALSE}
“`

### Step 2: Load the data and summarize

“`{r C2}
“`

### Step 3: Load the CUG and QAP utilities
“`{r C3}
“`

### Step 4: Reminder: CUG test for LOTR3 / Race
If we use “Race” feature as is, we will get an error because of zero values.
“`{r C4}
“`

### Step 5: Reminder QAP test for LOTR3 / Race

“`{r C5}

“`

### Step 6: Showing results
“`{r C6}
“`

## ERGM Example

We are looking at three networks.

### Load networks

“`{r C14}
“`

### Plotting

“`{r C15}
“`

### Triad census

Directed networks so we can look at the triad census

“`{r C16}

### Comparing metrics

Assortativity by color, density, transitivity, reciprocity

“`{r C17}
“`

### Plotting

Use melt to get a ggplot-friend graph.

Note: assortativity rising, density decreasing, transitivity / reciprocity not really changing

“`{r C18}
“`

### Convert to network

ERGM only works on network objects. The `intergraph` package provides the conversions.

“`{r C19}
“`

### Run some basic models

“`{r C20}
“`

### Load pre-computed models.

_Do this when your model fitting will take more than a minute or so._ You do not want to have to wait every time you generate the HTML.

“`{r C21}
“`

### Compare AIC of different models

“`{r C22}
“`

### Summaries of 3 and 6

“`{r C23}
“`

### Tweaking model 6
“`{r C24}
“`

### Fitting networks 4 and 5
“`{r C25}
“`

### Interpreting coefficients

Need the inverse logit function.

A Red->Blue edge is more than 20x more likely at time 3 than time 5. Mutual edges are equally likely in both times.

“`{r C26}
“`