mrp_table: Create individual-level marginal distribution table for MRP

Description Usage Arguments Details Value See Also Examples

Description

Creates a data frame object of class mrp.table that contains counts and proportions for the interactions between all demographic variables specified by model. The resulting output is designed (and required) for use in estimating cell predictions using the mrp_model function.

Usage

1

Arguments

model

formula: A list object containing column names in pop_data as separate formulae defining the model to use when creating the MRP table. See Details.

data

A R data frame containing population data, or a file path to read in data. If NULL, uses an internal dataset. If a file path is used, the file type must be one of .rds or .csv.

weights

numeric: Optional vector of weights to use when calculating counts and proportions.

Details

If data is not provided, then the function will use a preset data file created from the CPS Nov. 2012 voter survey.

The value passed to model must be a list object of column names in data, and each must also be passed as a formula. For example, to create a MRP table for the interaction between columns named ‘state’ and ‘sex’, the argument to model would be: list(~state, ~sex). Additionally, the first name in this list will be used to group final proportions by.

Value

A data frame containing counts and proportions for all unique interactions between the variables specified in model.

See Also

mrp_model, mrp_merge

Examples

1
2
3
4
5
## Create a five way interaction table, where the final proportions will be
## grouped by states.
model <- list(~state, ~sex, ~race4, ~hisp, ~inc3)

x <- mrp_table(model = model)

alexdulin/MCmrp documentation built on May 11, 2019, 11:29 p.m.