## with Willekens (1999) data
dn <- LETTERS[1:2]
y <- ipf2(row_tot = c(18, 20), col_tot = c(16, 22),
m = matrix(c(5, 1, 2, 7), ncol = 2,
dimnames = list(orig = dn, dest = dn)))
round(addmargins(y$mu),2)
## with all elements of offset equal
y <- ipf2(row_tot = c(18, 20), col_tot = c(16, 22))
round(addmargins(y$mu),2)
## with bigger matrix
dn <- LETTERS[1:3]
y <- ipf2(row_tot = c(170, 120, 410), col_tot = 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$mu))
## only one margin known
dn <- LETTERS[1:2]
y <- ipf2(row_tot = c(18, 20), col_tot = NULL,
m = matrix(c(5, 1, 2, 7), ncol = 2,
dimnames = list(orig = dn, dest = dn)))
round(addmargins(y$mu))
Run the code above in your browser using DataLab