Learn R Programming

mariposa (version 0.7.3)

multiple_response: Analyze Multiple Response Sets

Description

multiple_response() analyzes "check all that apply" survey questions — the SPSS MULT RESPONSE procedure. It takes a set of 0/1 indicator variables (one per answer option) and produces the two tables SPSS users know:

  • Without by: the frequencies table — number of mentions per option, percent of responses (sums to 100%), and percent of cases (sums above 100%, because respondents can tick several options).

  • With by: the crosstab of the set against a categorical variable — mentions and case-based column percentages per group.

Usage

multiple_response(data, ..., by = NULL, counted = 1, weights = NULL)

Value

An object of class "multiple_response" whose $results tibble holds one row per answer option (and group combination) with:

Option

Variable name of the option

Label

The option's variable label (falls back to the name)

n

Number of mentions (weighted sum when weighted)

pct_responses

Share of all mentions — sums to 100%

pct_cases

Share of valid cases mentioning the option — can sum above 100%

With by, $by_results additionally holds the long-form crosstab (columns by_level, Option, Label, n, pct_cases). $n_cases is the number of valid cases (at least one non-missing indicator), $n_responses the total number of mentions.

Arguments

data

Your survey data (a data frame or tibble). If grouped (via dplyr::group_by()), separate tables are produced per group (SPSS SPLIT FILE).

...

The indicator variables of the set (unquoted, supports tidyselect, e.g. starts_with("info_")). Each is checked against counted.

by

Optional categorical variable (unquoted) to cross the set against (SPSS MULT RESPONSE ... BY factor).

counted

The value that counts as a mention (default 1, matching SPSS dichotomy sets with counted value 1).

weights

Optional survey weights (unquoted variable name), treated as frequency weights matching SPSS WEIGHT BY.

Details

Understanding the Output

The two percentage columns answer different questions:

  • Percent of responses: "Of all boxes ticked, how many were this option?" — describes the mix of answers.

  • Percent of cases: "What share of respondents ticked this option?" — usually the number reports need. It sums above 100% whenever respondents tick more than one box.

Case handling

Following SPSS MULT RESPONSE, a case is valid if it has at least one non-missing indicator in the set; cases missing on all indicators are excluded and reported as missing. Within a valid case, missing indicators simply contribute no mention. With by, cases missing on the by variable are excluded too.

Technical Details

Weighted analyses count mentions and cases as unrounded sums of weights (Charter §5.1); displayed Ns are rounded. With weights == 1 the weighted table reduces exactly to the unweighted one. Only dichotomy sets (indicator + counted value) are supported; SPSS's category-range sets are not.

An SPSS v29 MULT RESPONSE reference run is pending; until it lands the counts and percentages are verified against direct hand-computation from the indicator matrix (see the SPSS compatibility vignette).

See Also

frequency for single-variable frequency tables.

crosstab for ordinary two-variable crosstabs.

summary.multiple_response for detailed output.

Other descriptive: crosstab(), describe(), frequency(), normality_test()

Examples

Run this code
library(dplyr)
data(survey_data)

# Build an example set: which institutions does a respondent
# trust highly (rating of 4 or 5)?
trust <- survey_data %>%
  mutate(
    gov     = as.integer(trust_government >= 4),
    media   = as.integer(trust_media >= 4),
    science = as.integer(trust_science >= 4)
  )

# Frequencies table: % of responses vs. % of cases
multiple_response(trust, gov, media, science)

# Crossed against gender, with weights
multiple_response(trust, gov, media, science,
                  by = gender, weights = sampling_weight)

# --- Three-layer output ---
result <- multiple_response(trust, gov, media, science)
result              # compact overview
summary(result)     # full detailed output

Run the code above in your browser using DataLab