| CompareMaxDev {mipfp} | R Documentation |
Comparing deviations of mipfp objects
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
CompareMaxDev(list.mipfp = list(), true.table = NULL, echo = FALSE)
Arguments
list.mipfp |
The list produced by the function |
true.table |
When provided, the estimates contained in the |
echo |
Verbose parameter. If |
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
# 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)