IPFP: Iterative Proportional Fitting Procedure

Description Usage Arguments Details Author(s) References Examples

View source: R/IPFP.r

Description

Adjustment of a table on the margins

Usage

1
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 Andres Gutierrez Rojas hagutierrezro@gmail.com

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.
Gutierrez, H. A. (2009), Estrategias de muestreo: Diseno de encuestas y estimacion de parametros. Editorial Universidad Santo Tomas.

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
############
## 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(Lucy)
attach(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)[,2:4]
est2 <-E.SI(N,n,SPAM.yes)[,2:4]
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 <- colSums(Domains(Lucy$SPAM))
Row.knw<- colSums(Domains(Lucy$Level))
# The adjusted table
IPFP(Table,Col.knw,Row.knw,tol=0.0001)

Example output

   b1  b2  b3
a1 80 170 150
a2 90  80 210
a3 10  80 130
               b1        b2       b3 Row.est
a1       73.00821 167.64061 189.3512     430
a2       69.39039  66.64928 223.9603     360
a3        7.60140  65.71011 136.6885     210
Col.est 150.00000 300.00000 550.0000    1000
The following objects are masked from Lucy:

    Employees, ID, Income, Level, SPAM, Taxes, Ubication, Zone

[1] 400   8
                  N      Big     Medium       Small
Estimation     2396 47.92000 754.740000 1593.340000
Standard Error    0 15.32729  50.855484   51.673806
CVE               0 31.98515   6.738146    3.243112
DEFF            NaN  1.00000   1.000000    1.000000
                  N         no         yes
Estimation     2396 964.390000 1431.610000
Standard Error    0  53.689471   53.689471
CVE               0   5.567195    3.750286
DEFF            NaN   1.000000    1.000000
                     Big    Medium      Small
Estimation     17.970000 287.52000 658.900000
Standard Error  9.445678  35.57699  48.884658
CVE            52.563593  12.37374   7.419132
DEFF            1.000000   1.00000   1.000000
                    Big     Medium      Small
Estimation     29.95000 467.220000 934.440000
Standard Error 12.16356  43.376297  53.399163
CVE            40.61290   9.283913   5.714563
DEFF            1.00000   1.000000   1.000000
          SPAM.no   SPAM.yes Row.est
Big      30.22642   52.77358      83
Medium  272.73124  464.26876     737
Small   634.04234  941.95766    1576
Col.est 937.00000 1459.00000    2396

TeachingSampling documentation built on April 22, 2020, 1:05 a.m.