IPFP {TeachingSampling}R Documentation

Iterative Proportional Fitting Procedure

Description

Adjustment of a table on the margins

Usage

IPFP(Table, Col.knw, Row.knw, tol=0.0001)

Arguments

Table A contingency table
Col.knw A vector containing the true totals of the columns
Row.knw A vector containing the true totals of the Rows
tol The control value, by default equal to 0.0001

Details

Adjust a contingency table on the know margins of the population with the Raking Ratio method

Author(s)

Hugo Andrés Gutiérrez Rojas hugogutierrez@usantotomas.edu.co

References

Deming, W. & Stephan, F. (1940), On a least squares adjustment of a sampled frequency table when the expected marginal totals are known. Annals of Mathematical Statistics, 11, 427-444.
Guti'errez, H. A. (2009), Estrategias de muestreo: Dise~no de encuestas y estimaci'on de par'ametros. Editorial Universidad Santo Tom'as.

Examples

############
## Example 1
############
# Some example of Ardilly and Tille 
Table <- matrix(c(80,90,10,170,80,80,150,210,130),3,3)
rownames(Table) <- c("a1", "a2","a3")
colnames(Table) <- c("b1", "b2","b3")
# The table with labels
Table
# The known and true margins
Col.knw <- c(150,300,550)
Row.knw <- c(430,360,210)
# The adjusted table
IPFP(Table,Col.knw,Row.knw,tol=0.0001)

############
## Example 2
############
# Draws a simple random sample
data(Marco)
data(Lucy)

N<-dim(Lucy)[1]
n<-400
sam<-sample(N,n)
data<-Lucy[sam,]
attach(data)
dim(data)
# Two domains of interest
Doma1<-Domains(Level)
Doma2<-Domains(SPAM)
# Cross tabulate of domains
SPAM.no<-Doma2[,1]*Doma1
SPAM.yes<-Doma2[,2]*Doma1
# Estimation
E.SI(N,n,Doma1)
E.SI(N,n,Doma2)
est1 <-E.SI(N,n,SPAM.no)
est2 <-E.SI(N,n,SPAM.yes)
est1;est2
# The contingency table estimated from above
Table <- cbind(est1[1,],est2[1,])
rownames(Table) <- c("Big", "Medium","Small")
colnames(Table) <- c("SPAM.no", "SPAM.yes")
# The known and true margins
Col.knw <- c(937,1459)
Row.knw<- c(83,737,1576)
# The adjusted table
IPFP(Table,Col.knw,Row.knw,tol=0.0001)

[Package TeachingSampling version 0.7.6 Index]