CompareMaxDev: Comparing deviations of mipfp objects

Description Usage Arguments Value Author(s) See Also Examples

View source: R/utils.R

Description

This function compares either the margins errors from different mipfp objects or the absolute maximum deviation between a given table and the estimates in the mipfp objects.

Usage

1
CompareMaxDev(list.mipfp = list(), true.table = NULL, echo = FALSE)

Arguments

list.mipfp

The list produced by the function Estimate.

true.table

When provided, the estimates contained in the mipfp objects in the list list.mipfp are compared against this table. It is an optional argument.

echo

Verbose parameter. If TRUE, the function prints what is being compared. Default is FALSE.

Value

A table with as many rows as the number of mipfp objects in list.mipfp. Each row details the margins errors or the maximum absolute deviation of one mipfp object.

Author(s)

Johan Barthelemy

Maintainer: Johan Barthelemy johan@uow.edu.au.

See Also

The estimation function Estimate.

This function is used by error.margins.mipfp.

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
# loading the data
data(spnamur, package = "mipfp")
# subsetting the data frame, keeping only the first 3 variables
spnamur.sub <- subset(spnamur, select = Household.type:Prof.status)
# true table
true.table <- table(spnamur.sub)
# extracting the margins
tgt.v1        <- apply(true.table, 1, sum)
tgt.v1.v2     <- apply(true.table, c(1,2), sum)
tgt.v2.v3     <- apply(true.table, c(2,3), sum)
tgt.list.dims <- list(1, c(1,2), c(2,3))
tgt.data      <- list(tgt.v1, tgt.v1.v2, tgt.v2.v3)
# creating the seed, a 10% sample of spnamur
seed.df <- spnamur.sub[sample(nrow(spnamur), round(0.10*nrow(spnamur))), ]
seed.table <- table(seed.df)
# applying the different fitting methods
r.ipfp <- Estimate(seed=seed.table, target.list=tgt.list.dims, 
                   target.data = tgt.data,  method = "ipfp")
r.ml   <- Estimate(seed = seed.table, target.list = tgt.list.dims, 
                   target.data = tgt.data, method = "ml")
r.chi2 <- Estimate(seed = seed.table, target.list = tgt.list.dims, 
                   target.data = tgt.data, method = "chi2")
r.lsq  <- Estimate(seed = seed.table, target.list = tgt.list.dims, 
                   target.data = tgt.data, method = "lsq")
# print the maximum absolute deviation between targets and generated margins
CompareMaxDev(list(r.ipfp,r.ml,r.chi2,r.lsq), echo = TRUE)
# compute the maximum absolute deviation between the true and estimated tables
CompareMaxDev(list(r.ipfp,r.ml,r.chi2,r.lsq), echo = TRUE, 
              true.table = true.table)

mipfp documentation built on May 2, 2019, 6:01 a.m.