Description Usage Arguments Value Author(s) References Examples

View source: R/assortment.continuous.R

Calculates the assortativity coefficient for weighted and unweighted graphs with numerical vertex values

1 | ```
assortment.continuous(graph, vertex_values, weighted = TRUE, SE = FALSE, M = 1)
``` |

`graph` |
A Adjacency matrix, as an N x N matrix. Can be weighted or binary. |

`vertex_values` |
Values on which to calculate assortment, vector of N numbers |

`weighted` |
Flag: TRUE to use weighted edges, FALSE to turn edges into binary (even if weights are given) |

`SE` |
Calculate standard error using the Jackknife method. |

`M` |
Binning value for Jackknife, where M edges are removed rather than single edges. This helps speed up the estimate for large networks with many edges. |

This function returns a named list, with two elements:

$r the assortativity coefficient $SE the standard error

Damien Farine dfarine@orn.mpg.de

Newman (2003) Mixing patterns in networks. Physical Review E (67) Farine, D.R. (2014) Measuring phenotypic assortment in animal social networks: weighted associations are more robust than binary edges. Animal Behaviour 89: 141-153.

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 | ```
# DIRECTED NETWORK EXAMPLE
# Create a random directed network
N <- 20
dyads <- expand.grid(ID1=1:20,ID2=1:20)
dyads <- dyads[which(dyads$ID1 != dyads$ID2),]
weights <- rbeta(nrow(dyads),1,15)
network <- matrix(0, nrow=N, ncol=N)
network[cbind(dyads$ID1,dyads$ID2)] <- weights
# Create random continues trait values
traits <- rnorm(N)
# Test for assortment as binary network
assortment.continuous(network,traits,weighted=FALSE)
# Test for assortment as weighted network
assortment.continuous(network,traits,weighted=TRUE)
# UNDIRECTED NETWORK EXAMPLE
# Create a random undirected network
N <- 20
dyads <- expand.grid(ID1=1:20,ID2=1:20)
dyads <- dyads[which(dyads$ID1 < dyads$ID2),]
weights <- rbeta(nrow(dyads),1,15)
network <- matrix(0, nrow=N, ncol=N)
network[cbind(dyads$ID1,dyads$ID2)] <- weights
network[cbind(dyads$ID2,dyads$ID1)] <- weights
# Create random continues trait values
traits <- rnorm(N)
# Test for assortment as binary network
assortment.continuous(network,traits,weighted=FALSE)
# Test for assortment as weighted network
assortment.continuous(network,traits,weighted=TRUE)
``` |

assortnet documentation built on May 19, 2017, 3:51 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.