ipf3: Iterative Proportional Fitting Routine for the Indirect...

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/ipf3.R

Description

The ipf3 function finds the maximum likelihood estimates for fitted values in the log-linear model:

\log y_{ijk} = \log α_{i} + \log β_{j} + \log λ_{k} + \log γ_{ik} + \log κ_{jk} + \log m_{ijk}

where m_{ijk} is a set of prior estimates for y_{ijk} and is no more complex than the matrices being fitted.

Usage

1
2
ipf3(rtot = NULL, ctot = NULL, m = NULL, tol = 1e-05, maxit = 500,
  verbose = TRUE)

Arguments

rtot

Vector of origin totals to constrain the sum of the imputed cell rows.

ctot

Vector of destination totals to constrain the sum of the imputed cell columns.

m

Array of auxiliary data. By default set to 1 for all origin-destination-migrant typologies 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 FALSE.

Value

Iterative Proportional Fitting routine set up in a similar manner to Agresti (2002, p.343). The arguments rtot and ctot take the row-table and column-table specific known 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) to 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

References

Abel, G. J. (2013). Estimating Global Migration Flow Tables Using Place of Birth. Demographic Research 28, (18) 505-546

Agresti, A. (2002). Categorical Data Analysis 2nd edition. Wiley.

See Also

ipf3_qi, ipf2

Examples

 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
## create row-table and column-table specific known margins.
dn <- LETTERS[1:4]
P1 <- matrix(c(1000, 100,  10,   0, 
               55,   555,  50,   5, 
               80,    40, 800 , 40, 
               20,    25,  20, 200), 
             nrow = 4, ncol = 4, byrow = TRUE, 
             dimnames = list(pob = dn, por = dn))
P2 <- matrix(c(950, 100,  60,   0, 
                80, 505,  75,   5, 
                90,  30, 800,  40, 
                40,  45,   0, 180), 
             nrow = 4, ncol = 4, byrow = TRUE, 
             dimnames = list(pob = dn, por = dn))
# display with row and col totals
addmargins(P1)
addmargins(P2)

# run ipf
y <- ipf3(rtot = t(P1), ctot = P2)
# display with row, col and table totals
round(addmargins(y$mu), 1)
# origin-destination flow table
round(od_sum(y$mu), 1)

## with alternative offset term
dis <- array(c(1, 2, 3, 4, 2, 1, 5, 6, 3, 4, 1, 7, 4, 6, 7, 1), c(4, 4, 4))
y <- ipf3(rtot = t(P1), ctot = P2, m = dis)
# display with row, col and table totals
round(addmargins(y$mu), 1)
# origin-destination flow table
round(od_sum(y$mu), 1) 

migest documentation built on Feb. 6, 2018, 1:02 a.m.