simulate_survey_continuous: Simulate a single survey to a question with a continuous...

Description Usage Arguments Details Examples

Description

Simulate a single survey to a question with a continuous numerical answer according to inputs

Usage

1
2
3
simulate_survey_continuous(prop_sex, lambda_sex, prop_raceethnicity,
  lambda_raceethnicity, prop_age, lambda_age, prop_education, lambda_education,
  prop_geography, lambda_geography, n = 1000)

Arguments

prop_sex

Numeric vector specifying the gender characteristics of the survey respondents as proportions in the order male, then female, for example, c(0.49, 0.51). Must sum to 1, i.e., all respondents fall into one of these gender bins.

lambda_sex

Numeric vector specifying lambda (Poisson distribution) for the survey respondents by sex in the order male, then female, for example, c(25, 75).

prop_raceethnicity

Numeric vector specifying the racial/ethnic characteristics of the survey respondendents as proportions in the order white alone, Hispanic or Latino, black alone, Asian alone, and other, for example, c(0.6, 0.22, 0.11, 0.05, 0.02). Must sum to 1, i.e., all respondents fall into one of these racial/ethnic bins.

lambda_raceethnicity

Numeric vector specifying lambda for the survey respondents by race/ethnicity in the same order as prop_raceethnicity, for example, c(90, 10, 50, 50, 50).

prop_age

Numeric vector specifying the age characteristics of the survey respondents as proportions 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(0.05, 0.1, 0.4, 0.3, 0.15). Must sum to 1, i.e., all respondents must fall into one of these age bins.

lambda_age

Numeric vector specifying lambda for survey respondents by age in the same order bins as prop_age, for example, c(50, 55, 75, 85, 95).

prop_education

Numeric vector specifying the educational attainment of the survey respondents as proportions in the following bins: less than high school diploma, high school graduate (includes equivalency), some college or associate's degree, bachelor's degree or higher, for example, c(0.1, 0.2, 0.4, 0.3). Must sum to 1, i.e., all respondents must fall into one of these educational attainment bins.

lambda_education

Numeric vector specifying lambda for the survey respondents by educational attainment in the same order bins as prop_education, for example, c(20, 40, 60, 80).

prop_geography

Numeric vector specifying the geography distribution of the survey respondents as proportions in the following bins: Texas, California, Utah, for example, c(0.5, 0, 0.5). Must sum to 1, i.e., all respondents must fall into one of these geography bins.

lambda_geography

Numeric vector specifying lambda for the survey respondents by geography in the same order bins as prop_geography, for example, c(10, 50, 90).

n

Number of respondents in the survey (default is 1000)

Details

The numerical value for each survey respondent is simulated using the Poisson distribution. The lambda value for each respondent is calculated by taking the mean of lambda for that respondent's sex, race/ethnicity, etc. Use NA for lambda to indicate that an indicator does not effect the survey result, for example, lambda_education = rep(NA, 4).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# prop_sex specifies how many men/women are in the survey
# in this example, the survey is 48% men and 52% women
prop_sex <- c(0.48, 0.52)
# lambda_sex specifies the response weights of men/women
# in this example, women have a higher mean response than men
lambda_sex <- c(25, 75)
prop_raceethnicity <- c(0.55, 0.25, 0.1, 0.05, 0.05)
lambda_raceethnicity <- c(90, 10, 50, 50, 50)
prop_age <- c(0.05, 0.1, 0.4, 0.3, 0.15)
lambda_age <- c(50, 55, 75, 85, 95)
prop_education <- c(0.1, 0.3, 0.4, 0.2)
lambda_education <- c(20, 40, 60, 80)
prop_geography <- c(0.4, 0.3, 0.3)
lambda_geography <- c(80, 60, 40)
mysurvey <- simulate_survey_continuous(prop_sex, lambda_sex,
                                     prop_raceethnicity, lambda_raceethnicity,
                                     prop_age, lambda_age,
                                     prop_education, lambda_education,
                                     prop_geography, lambda_geography,
                                     n = 900)

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