The `cm2`

function finds the maximum likelihood estimates for parameters in the log-linear model:

* \log y_{ij} = \log α_i + \log β_j + \log m_{ij} *

as introduced by Willekens (1999). The *α_i* and *β_j* represent background information related to the characteristics of the origin and destinations respectively. The *m_{ij}* factor represents auxiliary information on migration flows, which imposes its interaction structure onto the estimated flow matrix.

1 2 |

`rtot` |
Origin (row) totals to constrain indirect estimates to. |

`ctot` |
Destination (column) totals to constrain indirect estimates to. |

`m` |
Auxiliary matrix. By default set to 1 for all origin-destination combinations. |

`tol` |
Tolerance level for parameter estimation. |

`maxit` |
Maximum number of iterations for parameter estimation. |

`verbose` |
Print the parameter estimates at each iteration. By default |

Parameter estimates are obtained using the EM algorithm outlined in Willekens (1999). This is equivalent to a conditional maximization of the likelihood, as discussed by Raymer et. al. (2007). It also provides identical indirect estimates to those obtained from the `ipf2`

routine.

The user must ensure that the row and column totals are equal in sum. Care must also be taken to allow the dimension of the auxiliary matrix (`m`

) to equal those provided in the row (`rtot`

) and column (`ctot`

) arguments.

Returns a `list`

object with

`N ` |
Origin-Destination matrix of indirect estimates |

`theta ` |
Collection of parameter estimates |

Guy J. Abel

Raymer, J., G. J. Abel, and P. W. F. Smith (2007). Combining census and registration data to estimate detailed elderly migration flows in England and Wales. *Journal of the Royal Statistical Society: Series A (Statistics in Society)* 170 (4), 891–908.

Willekens, F. (1999). Modelling Approaches to the Indirect Estimation of Migration Flows: From Entropy to EM. *Mathematical Population Studies* 7 (3), 239–78.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
## with Willekens (1999) data
dn <- LETTERS[1:2]
y <- cm2(rtot = c(18, 20), ctot = c(16, 22), m = matrix(c(5, 1, 2, 7), ncol = 2,
dimnames = list(orig = dn, dest = dn)))
y
## with all elements of offset equal (independence fit)
y <- cm2(rtot = c(18, 20), ctot = c(16, 22))
y
## with bigger matrix
dn <- LETTERS[1:3]
y <- cm2(rtot = c(170, 120, 410), ctot = c(500, 140, 60),
m = matrix(c(50, 10, 220, 120, 120, 30, 545, 0, 10), ncol = 3,
dimnames = list(orig = dn, dest = dn)))
# display with row and col totals
round(addmargins(y$N))
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

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.