Estimate: Update an N-way table given target margins

Description Usage Arguments Value Note Author(s) References See Also Examples

View source: R/s3_mipfp.R

Description

This function provides several estimating methods to up multiway table (referred as the seed) subject to known constrains/totals: Iterative proportional fitting procedure (ipfp), maximum likelihood method (ml), minimum chi-squared (chi2) and weighted least squares (lsq). Note that the targets can also be multi-dimensional.

Usage

1
2
Estimate(seed, target.list, target.data, method = "ipfp", keep.input = FALSE,
         ...)

Arguments

seed

The initial multi-dimensional array to be updated. Each cell must be non-negative if method is ipfp or strictly positive when method is ml, lsq or chi2.

target.list

A list of dimensions of the marginal target constrains in target.data. Each component of the list is an array whose cells indicate which dimension the corresponding margin relates to.

target.data

A list containing the data of the target marginal tables. Each component of the list is an array storing a margin. The list order must follow the ordering defined in target.list. Note that the cells of the arrays must be non-negative.

method

An optional character string indicating which method is to be used to update the seed. This must be on of the strings "ipfp", "ml", "chi2", or "lsq". Default is "ipfp".

keep.input

A Boolean indicating if seed, target.data and target.list when set to TRUE.

...

Additionals argument that can be passed to the functions Ipfp and ObtainModelEstimates. See their respective documentation for more details.

Value

An object of class mipfp is a list containing at least the following components:

x.hat

An array with the same dimension of seed whose margins match those specified in target.list.

p.hat

An array with the same dimension of x.hat containing the updated cell probabilities, i.e. x.hat / sum(x.hat).

error.margins

A list returning, for each margin, the absolute maximum deviation between the desired and generated margin.

conv

A boolean indicating whether the algorithm converged to a solution.

evol.stp.crit

The evolution of the stopping criterion over the iterations (if selected method is "ipfp")).

solnp.res

The estimation process uses the solnp optimisation function from the R package Rsolnp and solnp.res is the corresponding object returned by the solver (if selected method is not "ipfp").

method

The selected method for estimation.

call

The matched call.

The will be also added if keep.input has been set to TRUE: seed, target.data, target.list.

Note

It is important to note that if the margins given in target.list are not consistent (i.e. the sums of their cells are not equals), the input data is then normalised by considering probabilities instead of frequencies:

Author(s)

Johan Barthelemy.

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

References

Bacharach, M. (1965). Estimating Nonnegative Matrices from Marginal Data. International Economic Review (Blackwell Publishing) 6 (3): 294-310.

Bishop, Y. M. M., Fienberg, S. E., Holland, P. W. (1975). Discrete Multivariate Analysis: Theory and Practice. MIT Press. ISBN 978-0-262-02113-5.

Deming, W. E., Stephan, F. F. (1940). On a Least Squares Adjustment of a Sampled Frequency Table When the Expected Marginal Totals are Known. Annals of Mathematical Statistics 11 (4): 427-444.

Fienberg, S. E. (1970). An Iterative Procedure for Estimation in Contingency Tables. Annals of Mathematical Statistics 41 (3): 907-917.

Little, R. J., Wu, M. M. (1991) Models for contingency tables with known margins when target and sampled populations differ. Journal of the American Statistical Association 86 (413): 87-95.

Lang, J.B. (2004) Multinomial-Poisson homogeneous models for contingency tables. Annals of Statistics 32(1): 340-383.

Stephan, F. F. (1942). Iterative method of adjusting frequency tables when expected margins are known. Annals of Mathematical Statistics 13 (2): 166-178.

See Also

See the functions Ipfp and ObtainModelEstimates for more details about the estimation process.

summary.mipfp for summaries, vcov.mipfp for the (asymptotic) covariance of the estimates and gof.estimates.mipfp for testing if the seed agrees with the targets.

The genereric functions print and coef.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# 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 pct sample of spnamur
seed.df <- spnamur.sub[sample(nrow(spnamur), round(0.10*nrow(spnamur))), ]
seed.table <- table(seed.df)
# applying one fitting method (ipfp)
r.ipfp <- Estimate(seed=seed.table, target.list=tgt.list.dims, 
                   target.data = tgt.data)
print(r.ipfp)

Example output

Loading required package: cmm
Loading required package: Rsolnp
Loading required package: numDeriv

Call:
Estimate(seed = seed.table, target.list = tgt.list.dims, target.data = tgt.data)

Method:  ipfp - convergence:  TRUE 

Estimates:
                                 
Household.type.Gender.Prof.status   Estimate
                            C.F.A  3747.2802
                            F.F.A  6530.1204
                            I.F.A  3108.6032
                            N.F.A  2287.9962
                            C.H.A  5224.7512
                            F.H.A 11053.9135
                            I.H.A  3377.4804
                            N.H.A  1889.8549
                            C.F.E  1075.4530
                            F.F.E  7831.2019
                            I.F.E   606.6285
                            N.F.E  2534.7165
                            C.H.E   763.8990
                            F.H.E  8316.6075
                            I.H.E  1080.6607
                            N.H.E  1905.8328
                            C.F.I  7022.2668
                            F.F.I 11784.6776
                            I.F.I  5015.7683
                            N.F.I  3452.2872
                            C.H.I  5828.3498
                            F.H.I  6919.4790
                            I.H.I  2393.8590
                            N.H.I  1496.3123

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