Learn R Programming

eiwild (version 0.6.7)

convertEiData: Extracting important values for ecological Inference

Description

Extracting important values for calculation of the ecological Inference with the runMBayes-function

Usage

convertEiData(form, aggr, indi = NULL, IDCols = c("ID"))

Arguments

form
formula in this format cbind(column_1,column_2, ...,column_c)~cbind(row_1,row_2,...,row_r))
aggr
data.frame with aggregate data. One district per line and one column giving one ID per district. (see Details)
indi
data.frame with individual data. One district per line and one column giving one ID per district. (see Details) If no individual data are present it defaults to NULL
IDCols
vector of length 2 giving the column-names or numbers of ID column

Value

list with components needed for the Metropolis algorithm in runMBayes

Details

indi is a districts x [(r*c)+1] data.frame containing one district per line. One column gives the ID of the districts which will be connection to the ID column in the aggr-data.frame.

For example a 2x3 ecological Inference problem with formula cbind(col1,col2,col3) ~ cbind(row1,row2) will have the row format : [ID, row1.col1, row1.col2, row1.col3, row2.col1, row2.col2, row2.col3]

It is important that the formula names correspond to the exact column number in the indi-data.frame.

See Also

runMBayes, mcmc tuneVars

Examples

Run this code
## Not run: 
# # loading some fake election data
# data(topleveldat)
# form <- cbind(CSU_2, SPD_2, LINK_2, GRUN_2) ~ cbind(CSU_1, SPD_1, Link_1)
# 
# conv <- convertEiData(form=form, aggr=aggr, indi=indi, IDCols=c("ID", "ID"))
# 
# str(conv)
# ## End(Not run)

Run the code above in your browser using DataLab