norm.network {CDatanet} | R Documentation |

## Creating objects for network models

### Description

`vec.to.mat`

creates a list of square matrices from a given vector.
The elements of the generated matrices are taken from the vector and placed column-wise (ie. the first column is filled up before filling the second column) and from the first matrix of the list to the last matrix of the list.
The diagonal of the generated matrices are zeros.
`mat.to.vec`

creates a vector from a given list of square matrices .
The elements of the generated vector are taken from column-wise and from the first matrix of the list to the last matrix of the list, while dropping the diagonal entry.
`norm.network`

row-normalizes matrices in a given list.

### Usage

```
norm.network(W)
vec.to.mat(u, N, normalise = FALSE, byrow = FALSE)
mat.to.vec(W, ceiled = FALSE, byrow = FALSE)
```

### Arguments

`W` |
matrix or list of matrices to convert. |

`u` |
numeric vector to convert. |

`N` |
vector of sub-network sizes such that |

`normalise` |
Boolean takes |

`byrow` |
Boolean takes |

`ceiled` |
Boolean takes |

### Value

a vector of size `sum(N*(N - 1))`

or list of `length(N)`

square matrices. The sizes of the matrices are `N[1], N[2], ...`

### See Also

### Examples

```
# Generate a list of adjacency matrices
## sub-network size
N <- c(250, 370, 120)
## rate of friendship
p <- c(.2, .15, .18)
## network data
u <- unlist(lapply(1: 3, function(x) rbinom(N[x]*(N[x] - 1), 1, p[x])))
W <- vec.to.mat(u, N)
# Convert G into a list of row-normalized matrices
G <- norm.network(W)
# recover u
v <- mat.to.vec(G, ceiled = TRUE)
all.equal(u, v)
```

*CDatanet*version 2.2.0 Index]