ipf2_block {migest} | R Documentation |
Iterative proportional fitting routine for the indirect estimation of origin-destination-type migration flow tables with known origin and destination margins and block diagonal elements.
Description
The ipf2.b
function finds the maximum likelihood estimates for fitted values in the log-linear model:
\log y_{pq} = \log \alpha_{p} + \log \beta_{q} + \log \lambda_{ij}I(p \in i, q \in j) + \log m_{pq}
where m_{pq}
is a prior estimate for y_{pq}
and is no more complex than the matrices being fitted. The \lambda_{ij}I(p \in i, q \in j)
term ensures a saturated fit on the block the (i,j)
block.
Usage
ipf2_block(
row_tot = NULL,
col_tot = NULL,
block_tot = NULL,
block = NULL,
m = NULL,
tol = 1e-05,
maxit = 500,
verbose = TRUE,
...
)
Arguments
row_tot |
Vector of origin totals to constrain the sum of the imputed cell rows. |
col_tot |
Vector of destination totals to constrain the sum of the imputed cell columns. |
block_tot |
Matrix of block totals to constrain the sum of the imputed cell blocks. |
block |
Matrix of block structure corresponding to |
m |
Matrix of auxiliary data. By default set to 1 for all origin-destination combinations. |
tol |
Numeric value for the tolerance level used in the parameter estimation. |
maxit |
Numeric value for the maximum number of iterations used in the parameter estimation. |
verbose |
Logical value to indicate the print the parameter estimates at each iteration. By default |
... |
Additional arguments passes to |
Value
Iterative Proportional Fitting routine set up using the partial likelihood derivatives. The arguments row_tot
and col_tot
take the row-table and column-table specific known margins. The block_tot
take the totals over the blocks in the matrix defined with b
. Diagonal values can be added by the user, but care must be taken to ensure resulting diagonals are feasible given the set of margins.
The user must ensure that the row and column totals in each table sum to the same value. Care must also be taken to allow the dimension of the auxiliary matrix (m
) equal those provided in the row and column totals.
Returns a list
object with
mu |
Array of indirect estimates of origin-destination matrices by migrant characteristic |
it |
Iteration count |
tol |
Tolerance level at final iteration |
Author(s)
Guy J. Abel
See Also
Examples
y <- ipf2_block(row_tot= c(30,20,30,10,20,5,0,10,5,5,5,10),
col_tot = c(45,10,10,5,5,10,50,5,10,0,0,0),
block_tot = matrix(data = c(0,0 ,50,0, 35,0,25,0, 10,10,0,0, 10,10,0,0),
nrow = 4, byrow = TRUE),
block = block_matrix(x = 1:16, b = c(2,3,4,3)))
addmargins(y$mu)