ecoBD: Calculating the Bounds for Ecological Inference in RxC Tables

View source: R/ecoBD.R

ecoBDR Documentation

Calculating the Bounds for Ecological Inference in RxC Tables

Description

ecoBD is used to calculate the bounds for missing internal cells of R \times C ecological table. The data can be entered either in the form of counts or proportions.

Usage

ecoBD(formula, data = parent.frame(), N = NULL)

Arguments

formula

A symbolic description of ecological table to be used, specifying the column and row margins of R \times C ecological tables. Details and specific examples are given below.

data

An optional data frame in which to interpret the variables in formula. The default is the environment in which ecoBD is called.

N

An optional variable representing the size of the unit; e.g., the total number of voters. If formula is entered as counts and the last row and/or column is omitted, this input is necessary.

Details

The data may be entered either in the form of counts or proportions. If proportions are used, formula may omit the last row and/or column of tables, which can be calculated from the remaining margins. For example, Y ~ X specifies Y as the first column margin and X as the first row margin in 2 \times 2 tables. If counts are used, formula may omit the last row and/or column margin of the table only if N is supplied. In this example, the columns will be labeled as X and not X, and the rows will be labeled as Y and not Y.

For larger tables, one can use cbind() and +. For example, cbind(Y1, Y2, Y3) ~ X1 + X2 + X3 + X4) specifies 3 \times 4 tables.

An R \times C ecological table in the form of counts:

n_{i11} n_{i12} ... n_{i1C} n_{i1.}
n_{i21} n_{i22} ... n_{i2C} n_{i2.}
... ... ... ... ...
n_{iR1} n_{iR2} ... n_{iRC} n_{iR.}
n_{i.1} n_{i.2} ... n_{i.C} N_i

where n_{nr.} and n_{i.c} represent the observed margins, N_i represents the size of the table, and n_{irc} are unknown variables. Note that for each i, the following deterministic relationships hold; n_{ir.} = ∑_{c=1}^C n_{irc} for r=1,…,R, and n_{i.c}=∑_{r=1}^R n_{irc} for c=1,…,C. Then, each of the unknown inner cells can be bounded in the following manner,

\max(0, n_{ir.}+n_{i.c}-N_i) ≤ n_{irc} ≤ \min(n_{ir.}, n_{i.c}).

If the size of tables, N, is provided,

An R \times C ecological table in the form of proportions:

W_{i11} W_{i12} ... W_{i1C} Y_{i1}
W_{i21} W_{i22} ... W_{i2C} Y_{i2}
... ... ... ... ...
W_{iR1} W_{iR2} ... W_{iRC} Y_{iR}
X_{i1} X_{i2} ... X_{iC}

where Y_{ir} and X_{ic} represent the observed margins, and W_{irc} are unknown variables. Note that for each i, the following deterministic relationships hold; Y_{ir} = ∑_{c=1}^C X_{ic} W_{irc} for r=1,…,R, and ∑_{r=1}^R W_{irc}=1 for c=1,…,C. Then, each of the inner cells of the table can be bounded in the following manner,

\max(0, (X_{ic} + Y_{ir}-1)/X_{ic}) ≤ W_{irc} ≤ \min(1, Y_{ir}/X_{ir}).

Value

An object of class ecoBD containing the following elements (When three dimensional arrays are used, the first dimension indexes the observations, the second dimension indexes the row numbers, and the third dimension indexes the column numbers):

call

The matched call.

X

A matrix of the observed row margin, X.

Y

A matrix of the observed column margin, Y.

N

A vector of the size of ecological tables, N.

aggWmin

A three dimensional array of aggregate lower bounds for proportions.

aggWmax

A three dimensional array of aggregate upper bounds for proportions.

Wmin

A three dimensional array of lower bounds for proportions.

Wmax

A three dimensional array of upper bounds for proportions.

Nmin

A three dimensional array of lower bounds for counts.

Nmax

A three dimensional array of upper bounds for counts.

The object can be printed through print.ecoBD.

References

Imai, Kosuke, Ying Lu and Aaron Strauss. (2011) “eco: R Package for Ecological Inference in 2x2 Tables” Journal of Statistical Software, Vol. 42, No. 5, pp. 1-23.

Imai, Kosuke, Ying Lu and Aaron Strauss. (2008) “Bayesian and Likelihood Inference for 2 x 2 Ecological Tables: An Incomplete Data Approach” Political Analysis, Vol. 16, No. 1, (Winter), pp. 41-69.

See Also

eco, ecoNP

Examples



## load the registration data
data(reg)

## calculate the bounds
res <- ecoBD(Y ~ X, N = N, data = reg)
## print the results
print(res)


eco documentation built on Nov. 4, 2022, 1:07 a.m.

Related to ecoBD in eco...