Learn R Programming

eco (version 2.2-2)

ecoBD: 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.

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):
  • callThe matched call.
  • XA matrix of the observed row margin, $X$.
  • YA matrix of the observed column margin, $Y$.
  • NA vector of the size of ecological tables, $N$.
  • aggWminA three dimensional array of aggregate lower bounds for proportions.
  • aggWmaxA three dimensional array of aggregate upper bounds for proportions.
  • WminA three dimensional array of lower bounds for proportions.
  • WmaxA three dimensional array of upper bounds for proportions.
  • NminA three dimensional array of lower bounds for counts.
  • NmaxA three dimensional array of upper bounds for counts.
  • The object can be printed through print.ecoBD.

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. 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: lcccc{ $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.} = \sum_{c=1}^C n_{irc}$ for $r=1,\dots,R$, and $n_{i.c}=\sum_{r=1}^R n_{irc}$ for $c=1,\dots,C$. Then, each of the unknown inner cells can be bounded in the following manner, $$\max(0, n_{ir.}+n_{i.c}-N_i) \le n_{irc} \le \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: lcccc{ $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} = \sum_{c=1}^C X_{ic} W_{irc}$ for $r=1,\dots,R$, and $\sum_{r=1}^R W_{irc}=1$ for $c=1,\dots,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}) \le W_{irc} \le \min(1, Y_{ir}/X_{ir}).$$

References

Imai, Kosuke. (2005) Ecological Inference in $R \times C$ Tables Working Paper, Princeton University.

See Also

eco, ecoNP

Examples

Run this code
## load the registration data
data(reg)

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

Run the code above in your browser using DataLab