Description Usage Arguments Examples
Simulate a single survey to a yes/no response question according to inputs
1 2 3 | simulate_survey(prop_sex, odds_sex, prop_raceethnicity, odds_raceethnicity,
prop_age, odds_age, prop_education, odds_education, prop_geography,
odds_geography, n = 1000)
|
prop_sex |
Numeric vector specifying the gender characteristics of the
survey respondents as proportions in the order male, then female, for
example, |
odds_sex |
Numeric vector specifying the opinion odds of the survey
respondents by sex in the order male, then female. For example, |
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, |
odds_raceethnicity |
Numeric vector specifying the opinion odds of
the survey respondents by race/ethnicity in the same order as
|
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,
|
odds_age |
Numeric vector specifying the opinion odds of the
survey respondents by age in the same order bins as |
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,
|
odds_education |
Numeric vector specifying the opinion odds of the survey
respondents by educational attainment in the same order bins as
|
prop_geography |
Numeric vector specifying the geography distribution
of the survey respondents as proportions in the following bins: Texas,
California, Utah, for example,
|
odds_geography |
Numeric vector specifying the opinion odds of the
survey respondents by geography in the same order bins as
|
n |
Number of respondents in the survey (default is 1000) |
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)
# odds_sex specifies the opinions of men/women
# in this example, women are twice as likely to approve and men half as likely
odds_sex <- c(0.5, 2)
prop_raceethnicity <- c(0.55, 0.25, 0.1, 0.05, 0.05)
odds_raceethnicity <- c(0.2, 2, 2.5, 1, 1)
prop_age <- c(0, 0.1, 0.4, 0.3, 0.2)
odds_age <- c(1, 0.8, 2, 3, 0.2)
prop_education <- c(0.1, 0.3, 0.4, 0.2)
odds_education <- c(0.4, 0.5, 2, 2.5)
prop_geography <- c(0.4, 0.3, 0.3)
odds_geography <- c(2, 1, 0.5)
mysurvey <- simulate_survey(prop_sex, odds_sex,
prop_raceethnicity, odds_raceethnicity,
prop_age, odds_age,
prop_education, odds_education,
prop_geography, odds_geography,
n = 900)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.