Description Usage Arguments Value Author(s) References Examples
Creates data.frame() table from eiPack RxC output, in the same format as ei_est_gen
1 | bayes_table_make(ei_bayes_object, cand_vector, table_names)
|
ei_bayes_object |
Output from eiPack ei.reg.bayes() function |
cand_vector |
Character vector of candidate name variables, usually "pct_johns" or something |
table_names |
Character vector of column names, e.g., c("RxC: Pct Hisp", "RxC: Pct Asian") |
Data frame object in similar vein to ei_est_gen
Loren Collingwood <loren.collingwood@ucr.edu>
O. Lau, R. T. Moore, and M. Kellermann. eipack: RxC ecological inference and higher-dimension data management. New Functions for Multivariate Analysis, 18(1):43, 2006.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | # TOY DATA EXAMPLE
canda <- runif(5)
candb <- 1-canda
white <- runif(5)
black <- 1 - white
total <- round( runif(5, min=20, max=40), 0)
toy <- data.frame(canda, candb, white, black, total)
cands <- c("canda", "candb")
table_names <- c("RxC: PCT Black", "RxC PCT White")
# Generate formula for passage to ei.reg.bayes() function
form <- formula(cbind(canda,candb) ~ cbind(black, white))
# Run Bayesian model
suppressWarnings (
ei_bayes <- ei.reg.bayes(form, data=toy, sample=100, truncate=TRUE)
)
# Table Creation, using function bayes_table_make
ei_bayes_res <- bayes_table_make(ei_bayes, cand_vector= cands, table_names = table_names)
ei_bayes_res
# Load Package Data
data(corona)
# Create Character Vectors
cands <- c("pct_husted","pct_spiegel","pct_ruth","pct_button","pct_montanez","pct_fox")
table_names <- c("RxC: Pct Hisp", "RxC: Pct Asian", "RxC: Pct White")
# Generate formula for passage to ei.reg.bayes() function
form <- formula(cbind(pct_husted,pct_spiegel,pct_ruth,pct_button,pct_montanez,pct_fox)
~ cbind(pct_hisp, pct_asian, pct_white))
# Run Bayesian model
suppressWarnings (
ei_bayes <- ei.reg.bayes(form, data=corona, sample=10000, truncate=TRUE)
)
# Table Creation, using function bayes_table_make
ei_bayes_res <- bayes_table_make(ei_bayes, cand_vector= cands, table_names = table_names)
ei_bayes_res
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.