# ei: Ecological Inference Estimation In ei: Ecological Inference

## Description

`ei` is the main command in the package `EI`. It gives observation-level estimates (and various related statistics) of β_i^b and β_i^w given variables T_i and X_i (i=1,...,n) in this accounting identity: T_i=β_i^b*X_i + β_i^w*(1-X_i). Results are stored in an `ei` object, that can be read with `summary()` or `eiread()` and graphed in `plot()`.

## Usage

 ```1 2 3 4 5 6``` ```ei(formula, total = NULL, Zb = 1, Zw = 1, id = NA, data =NA, erho = 0.5, esigma = 0.5, ebeta = 0.5, ealphab = NA, ealphaw = NA, truth = NA, simulate = TRUE, covariate = NULL, lambda1 = 4, lambda2 = 2, covariate.prior.list = NULL, tune.list = NULL, start.list = NULL, sample = 1000, thin = 1, burnin = 1000, verbose = 0, ret.beta = "r", ret.mcmc = TRUE, usrfun = NULL) ```

## Arguments

 `formula` A formula of the form t ~x in the 2x2 case and cbind(col1,col2,...) ~ cbind(row1,row2,...) in the RxC case. `total` ‘total’ is the name of the variable in the dataset that contains the number of individuals in each unit `Zb` p x k^b matrix of covariates or the name of covariates in the dataset `Zw` p x k^w matrix of covariates or the name of covariates in the dataset `id` ‘id’ is the nae of the variable in the dataset that identifies the precinct. Used for ‘movie’ and ‘movieD’ plot functions. `data` data frame that contains the variables that correspond to formula. If using covariates and data is specified, data should also contain `Zb` and `Zw`. `erho` The standard deviation of the normal prior on φ_5 for the correlation. Default =0.5. `esigma` The standard deviation of an underlying normal distribution, from which a half normal is constructed as a prior for both \breve{σ}_b and \breve{σ}_w. Default = 0.5 `ebeta` Standard deviation of the "flat normal" prior on \breve{B}^b and \breve{B}^w. The flat normal prior is uniform within the unit square and dropping outside the square according to the normal distribution. Set to zero for no prior. Setting to positive values probabilistically keeps the estimated mode within the unit square. Default=0.5 `ealphab` cols(Zb) x 2 matrix of means (in the first column) and standard deviations (in the second) of an independent normal prior distribution on elements of α^b. If you specify Zb, you should probably specify a prior, at least with mean zero and some variance (default is no prior). (See Equation 9.2, page 170, to interpret α^b). `ealphaw` cols(Zw) x 2 matrix of means (in the first column) and standard deviations (in the second) of an independent normal prior distribution on elements of α^w. If you specify Zw, you should probably specify a prior, at least with mean zero and some variance (default is no prior). (See Equation 9.2, page 170, to interpret α^w). `truth` A length(t) x 2 matrix of the true values of the quantities of interest. `simulate` default = TRUE:see documentation in `eiPack` for options for RxC ei. `covariate` see documentation in `eiPack` for options for RxC ei. `lambda1` default = 4:see documentation in `eiPack` for options for RxC ei. `lambda2` default = 2:see documentation in `eiPack` for options for RxC ei. `covariate.prior.list` see documentation in `eiPack` for options for RxC ei. `tune.list` see documentation in `eiPack` for options for RxC ei. `start.list` see documentation in `eiPack` for options for RxC ei. `sample` default = 1000 `thin` default = 1 `burnin` default = 1000 `verbose` default = 0:see documentation in `eiPack` for options for RxC ei. `ret.beta` default = "r": see documentation in `eiPack` for options for RxC ei. `ret.mcmc` default = TRUE: see documentation in `eiPack` for options for RxC ei. `usrfun` see documentation in `eiPack` for options for RxC ei.

## Details

The `EI` algorithm is run using the `ei` command. A summary of the results can be seen graphically using `plot(ei.object)` or numerically using `summary(ei.object)`. Quantities of interest can be calculated using `eiread(ei.object)`.

## Author(s)

Gary King <<email: king@harvard.edu>> and Molly Roberts <<email: molly.e.roberts@gmail.com>>

## References

Gary King (1997). A Solution to the Ecological Inference Problem. Princeton: Princeton University Press.

## Examples

 ```1 2 3 4``` ```data(sample) form <- t ~ x dbuf <- ei(form,total="n",data=sample) summary(dbuf) ```

ei documentation built on May 2, 2019, 11:02 a.m.