Description Usage Arguments Value Author(s) See Also Examples

**Experimental** function, which tries to adjust a given contact matrix
such that the stationary distribution of its row-normalized version (i.e.,
the transition matrix) becomes approximately equal to a prespecified
probability vector.

1 |

`C` |
a square numeric (contact) matrix. |

`target` |
the stationary probability vector to approximate. |

`eps` |
the tolerated mean absolute difference between the target probabilities and the stationary distribution of the adapted, normalized contact matrix. |

`iter.max` |
maximum number of iterations (guard against infinite loop). |

the adapted, normalized contact matrix.

Leonhard Held (original) and Sebastian Meyer (this implementation)

`adaptP`

for an alternative method.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ```
GROUPING <- c(1, 2, 2, 4, 4, 2)
C <- contactmatrix(grouping = GROUPING)
popBErbyg <- aggregateCountsArray(pop2011, dim = 2, grouping = GROUPING)
popfracs <- prop.table(colSums(popBErbyg))
## adapt 'C' to the given population fractions
Cpop <- C2pop(C, popfracs)
## compare the stationary distributions
compstat <- cbind(before = stationary(C/rowSums(C)), popBE = popfracs,
after = stationary(Cpop))
matplot(compstat, type="b", lty=1, ylim=c(0, max(compstat)),
xlab="age group", ylab="population fraction")
## compare the normalized contact matrices
print(plotC(C/rowSums(C), main="original", at=seq(0,0.6,length.out=17)),
split=c(1,1,2,1), more=TRUE)
print(plotC(Cpop, main="adapted", at=seq(0,0.6,length.out=17)),
split=c(2,1,2,1), more=FALSE)
``` |

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.