| Age band | Unweighted | Weighted | Shift |
|---|---|---|---|
| 18-29 | 91.7% | 89.6% | -2.1 pts |
| 30-49 | 88.6% | 87.3% | -1.3 pts |
| 50-64 | 79.9% | 77.9% | -2.0 pts |
| 65+ | 64.0% | 60.4% | -3.7 pts |
Rebuild Table 1 with the survey weight
Optional bonus · weighted estimates with the survey package
Optional — after the M05 lab, any time. Nothing here goes into your lab notebook, and none of it is graded.
Your Table 1 counts every respondent once, which makes it a description of the people who answered Wave 163 — not automatically a description of all U.S. adults. This page shows what changes when you apply Pew’s survey weight, to the table and to a chart. You will want both for Project 1.
Rebuild Table 1 with the survey weight
Your Table 1 counts every respondent once. That makes it a description of the people who answered Wave 163, not automatically a description of all U.S. adults. Pew therefore supplies WEIGHT_W163, the wave-specific survey weight used to make population estimates from this sample.
A useful way to think about the weight is relative influence. In the unweighted table, every respondent contributes exactly 1. In a weighted estimate, respondents contribute different amounts so that the sample better reflects the U.S. adult population on the dimensions Pew used in its weighting process. For Wave 163, that process begins with selection probabilities, adjusts for nonresponse and differential wave selection, calibrates to population benchmarks such as age, education, race and ethnicity, region, and party, and trims extreme weights to limit the loss of precision.
You selected WEIGHT_W163 back in Step 4 and then never used it. Here is what changes when you do.
The survey package works by first creating a survey-design object. The public Wave 163 file gives us Pew’s final analysis weight, but it does not give us the full internal design information Pew uses to reproduce its published margins of error. For the descriptive percentages below, we therefore create a weights-only design:
library(survey)
library(gtsummary)
library(gt)
# ids = ~1 says that we are not supplying cluster identifiers.
# For this exercise, the object is being used to apply Pew's final weight
# to the descriptive estimates in the table.
pew_design <- svydesign(
ids = ~ 1,
weights = ~ WEIGHT_W163,
data = pew |> filter(!is.na(any_social_media))
)
pew_design |>
tbl_svysummary(
by = any_social_media,
include = c(F_AGECAT, F_GENDER, F_EDUCCAT, F_RACETHNMOD, F_PARTY_FINAL),
missing = "ifany"
) |>
add_overall(last = TRUE) |>
as_gt() |>
tab_header(
title = md("**Table 1.** Characteristics of U.S. adults"),
subtitle = md("American Trends Panel Wave 163 · *weighted estimates*")
)Compare it with your unweighted table. The percentages shift — modestly for many rows, more for some. Age gives a clean example: adults 18–29 are 15.2% of the respondents in the analytic sample but 19.8% of the weighted estimate, a +4.6 percentage-point shift. The weighted result is telling you that the responding sample’s age composition did not exactly match the population benchmark, so the final weight changes how much different respondents contribute.
Social-media use moves too — from 81.0% in the unweighted analytic sample to 79.5% in the weighted population estimate. The direction is worth noticing because you cannot predict it from one demographic margin alone. Although weighting increases the contribution of younger adults in this wave, the weight is calibrated across many dimensions simultaneously. Within every age band in these data, respondents receiving larger weights also report social-media use at somewhat lower rates. Those adjustments combine to move the overall estimate downward.
A survey weight is not a single story about who is “missing.” It is the end product of several adjustments working at once. Which way it moves a particular estimate is therefore an empirical question: calculate the weighted estimate rather than trying to infer its direction from one characteristic.
Notice that the title changed too. The unweighted table describes the 5,078 respondents in the analytic sample. The weighted table uses Pew’s final survey weight to estimate characteristics of U.S. adults. Those are different statistical targets, so the prose surrounding the table should say which one you mean.
ids = ~1 leave out?
Wave 163 was not literally a simple random sample. Pew recruited the ATP through probability sampling, used a stratified wave sample, oversampled non-Hispanic Black and non-Hispanic Asian adults in Wave 163, and then constructed a final weight through a multistep process. Pew’s methodology also reports that its sampling errors account for the effect of weighting.
The public-use file gives you WEIGHT_W163, which is enough to reproduce Pew-style weighted point estimates such as percentages and means. It does not, however, expose all of the internal information Pew used to calculate the official margins of sampling error. That means svydesign(ids = ~1, weights = ~WEIGHT_W163, ...) should not be read as “Pew’s full survey design.” It is a weights-only representation built from the information available in the public file.
For today’s purpose — seeing how weighting changes the descriptive Table 1 — that is exactly what we need. When we turn to confidence intervals in M07, you will work with a survey dataset that supplies the design variables needed for design-based standard errors as well as the weight.
Pew reports a ±1.6 percentage-point margin of sampling error for the full Wave 163 sample. Treat that published value as Pew’s result; do not try to reverse-engineer it from WEIGHT_W163 alone.
Weighting a chart, too
Tables are not the only place weights matter. For Project 1, your figures may make claims about U.S. adults, so the same distinction carries into visualization.
For a chart that is built from counts or proportions, ggplot2 can use a weight aesthetic. Without it, each respondent contributes 1. With it, each respondent contributes their survey weight:
pew_chart <- pew |>
filter(!is.na(any_social_media), !is.na(F_AGECAT))
pew_chart |>
ggplot(aes(x = F_AGECAT, fill = any_social_media)) +
geom_bar(aes(weight = WEIGHT_W163), position = "fill") +
scale_y_continuous(labels = scales::percent) +
scale_fill_manual(values = c("No" = "#E8ECF1", "Yes" = "#4E5EAA")) +
labs(
title = "Social media use by age, weighted to U.S. adults",
x = NULL, y = NULL, fill = "Uses social media"
) +
theme_minimal(base_size = 13)Delete aes(weight = WEIGHT_W163) and you have the unweighted version. You can also calculate the two sets of percentages directly:
pew_chart |>
group_by(F_AGECAT) |>
summarize(
unweighted = 100 * mean(any_social_media == "Yes"),
weighted = 100 * weighted.mean(any_social_media == "Yes", WEIGHT_W163),
.groups = "drop"
) |>
mutate(shift = weighted - unweighted)This is the within-age-band picture behind the table above: in this wave, the weighted estimate of social-media use is lower within every age band, with the largest shift among adults 65+ (-3.7 points). That does not mean “age caused the weighting correction.” It means the final weight is carrying information from several weighting dimensions at once, and the people receiving relatively more influence within each age group happen, in these data, to report social-media use at lower rates.
The rule to carry into Project 1: match the claim to the calculation. An unweighted chart describes the respondents you analyzed. A chart that applies Pew’s wave-specific weight is intended to estimate the corresponding pattern among U.S. adults. Make that distinction visible in the title, subtitle, caption, or methods note — a reader cannot infer it from the bars alone.
And keep one more distinction in reserve for M07: weighting a point estimate and estimating its uncertainty are separate jobs. The weight aesthetic above changes the estimate; it does not create a confidence interval or reproduce Pew’s official margin of error. You will learn that second job when we build confidence intervals from the ground up.