election: Simulate the outcome of an election based on polling data

Description Usage Arguments Examples

Description

Takes a data table with polling information about A/B preferences and covariates for each polled individual. Fit's the specified model of outcome and runs 100 simulated elections with a total electorate size of N (as opposed to the poll size n).

Usage

1
election(formula, data, N = 1000, weights = NULL, turnout = 1)

Arguments

formula
  • the model of individual vote outcome

data
  • the data table containing the polling sample

N
  • the size of the electorate

weights
  • one-sided formula giving variable to be used for weights

turnout
  • a fraction (e.g. 0.60) or a one-sided formula giving the name of the variable expressing turnout probability for each voter in the poll. NOT YET IMPLEMENTED.

Examples

1
2
D <- data.frame(response = c(0,0,1,1,1,1), weight = 1:6, sex = c("M", "F", "M", "F", "F", "F"))
election(response ~ 1, D, N = 1000)

dtkaplan/statPREPpackage documentation built on May 15, 2019, 5:22 p.m.