simulate_true_response_age: Simulate the true response to a yes/no response question in a...

Description Usage Arguments Value Examples

Description

Simulate the true response to a yes/no response question in a given population with specified opinions for sex, race/ethnicity, age, and geography

Usage

1
2
simulate_true_response_age(geovector, odds_geography, odds_sex,
  odds_raceethnicity, odds_age)

Arguments

geovector

A vector of geographies specified as a two letter abbreviation or a 5-digit FIPS code. Each geography must be the entire U.S. (US) or a single state (for example, TX or CA) or a single county (for example, 49035). For example, c("TX", "UT").

odds_geography

Numeric vector specifying the opinion odds of the survey respondents by geography in the same bins as geovector.

odds_sex

Numeric vector specifying the opinion odds of the survey respondents by sex in the order male, then female. For example, c(0.8, 1.25) means that men are 0.8 times as likely to approve the survey question and women are 1.25 times as likely to approve the survey question.

odds_raceethnicity

Numeric vector specifying the opinion odds of the survey respondents by race/ethnicity in the order white alone, Hispanic or Latino, black alone, Asian alone, and other, for example, c(0.2, 2, 2.5, 1, 1).

odds_age

Numeric vector specifying the opinion odds of the survey respondents by age in the following bins: under 18 years, 18 to 24 years, 25 to 44 years, 45 to 64 years, 65 years and over, for example, c(1, 0.5, 2, 2.5, 2.5).

Value

A data frame with 3 columns (value, answer, and result) that tabulates the true opinion on the yes/no question in the given population.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
geovector <- c("AL", "CT")
odds_geography <- c(1.5, 0.8)
odds_sex <- c(0.5, 2)
odds_raceethnicity <- c(0.2, 2, 2.5, 1, 1)
odds_age <- c(1, 0.5, 2, 2.5, 2.5)
opinionDF <- simulate_true_response_age(geovector,
                                     odds_geography, 
                                     odds_sex, 
                                     odds_raceethnicity,
                                     odds_age)

heathermkrause/WWC documentation built on May 17, 2019, 3:20 p.m.