library(tidyverse)
# In your own class folder this path is just "Data/anes.csv"
anes <- read_csv("../Slides/Data/anes.csv", show_col_types = FALSE)You Try Answers: Describing Data
POSC 8410
You Try (1): Describing ft_blm
1. Compute the mean, median, and standard deviation of ft_blm.
All three go in one summarise(). na.rm = TRUE matters here: 109 respondents have no BLM rating, and missing values make the whole summary NA.
anes |>
summarise(mean_blm = mean(ft_blm, na.rm = TRUE),
median_blm = median(ft_blm, na.rm = TRUE),
sd_blm = sd(ft_blm, na.rm = TRUE))# A tibble: 1 × 3
mean_blm median_blm sd_blm
<dbl> <dbl> <dbl>
1 53.3 60 35.4
The mean is 53.3, the median 60, and the standard deviation 35.4.
Two things are already worth noticing before plotting. First, the mean is about 7 points below the median. Something is pulling the mean down, which suggests a pile of respondents at the cold end of the scale. Second, a standard deviation of 35 on a 0–100 scale is very large. The typical respondent is more than a third of the scale away from the mean. That is what a polarized public looks like in a summary statistic.
2. Plot its distribution using a histogram. Is it skewed? Bimodal?
anes |>
filter(!is.na(ft_blm)) |>
ggplot(aes(x = ft_blm)) +
geom_histogram(binwidth = 5, boundary = 0, fill = "#522D80") +
labs(x = "Feeling thermometer: Black Lives Matter",
y = "Respondents")I set binwidth = 5 with boundary = 0 so each bar covers a clean five-point range. The default bins = 30 works too. Try a few settings, as we discussed in class.
Both. The distribution is bimodal, with its two peaks at opposite ends of the scale. The single most common rating is 0 (19% of respondents give BLM the coldest possible rating), and the next most common is 100 (16%). Altogether, 31% rate BLM 85 or higher. Like affect_gap in the slides, this is what a polarized attitude looks like.
It is also left-skewed overall, because the larger hump is on the warm side and the pile at 0 forms a long tail to the left. That is why the mean (53.3) falls below the median (60).
You may also have noticed that the histogram is spiky. People do not use the thermometer evenly:
anes |>
count(ft_blm, sort = TRUE) |>
head(10)# A tibble: 10 × 2
ft_blm n
<dbl> <int>
1 0 1380
2 100 1143
3 85 886
4 50 737
5 70 732
6 60 568
7 15 417
8 40 397
9 30 320
10 90 158
The nine most common values are 0, 15, 30, 40, 50, 60, 70, 85, and 100. These are the points labelled on the thermometer the ANES shows respondents, and people round to them. This is the measurement point from class: we treat the thermometer as an interval scale running from 0 to 100, but respondents use it more like a nine-point ordinal scale. That doesn’t make it useless, but you should know what you are assuming.
3. Make a boxplot of ft_blm by votechoice.
The grouping variable goes on the x-axis and the continuous variable on the y-axis. I drop respondents with no vote choice so there is no NA box.
anes |>
filter(!is.na(votechoice), !is.na(ft_blm)) |>
ggplot(aes(x = votechoice, y = ft_blm)) +
geom_boxplot(fill = "grey85") +
labs(x = NULL,
y = "Feeling thermometer: Black Lives Matter")The partisan gap is enormous. The median Biden voter rates BLM at 85, and the median Trump voter at 15.
4. Which group has more internal disagreement? How can you tell from the box?
The height of the box is the interquartile range (IQR): the spread of the middle 50% of the group. A taller box means more disagreement among typical members of the group. The whiskers add information about the tails.
Reading the plot, the Other box is tallest. The Biden and Trump boxes look the same height. The numbers confirm it:
spread <- anes |>
filter(!is.na(votechoice), !is.na(ft_blm)) |>
group_by(votechoice) |>
summarise(n = n(),
q1 = quantile(ft_blm, 0.25),
median = median(ft_blm),
q3 = quantile(ft_blm, 0.75),
iqr = IQR(ft_blm),
sd = sd(ft_blm))
spread# A tibble: 3 × 7
votechoice n q1 median q3 iqr sd
<chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
1 Biden 3242 60 85 100 40 21.7
2 Other 147 40 55 85 45 28.9
3 Trump 2426 0 15 40 40 24.9
Three points:
“Other” voters are the most divided by both measures (IQR 45, SD 28.9). That makes sense: “Other” lumps together everyone who voted for neither major candidate (Libertarians, Greens, write-ins), and those voters have little in common politically. But it is only 147 people.
Biden and Trump voters have identical IQRs (40 points each), so the boxes alone cannot separate them. The standard deviation says Trump voters are somewhat more spread out (24.9 versus 21.7). The two measures can disagree because the IQR ignores the tails entirely, while the SD squares each deviation and thus weights the tails heavily. Trump voters have a somewhat longer tail of warm ratings than Biden voters have of cold ones: 10% of Trump voters rate BLM at least 45 points warmer than their group’s median, while 8% of Biden voters rate it at least 45 points colder than theirs.
Watch the ends of the scale. The Biden box runs all the way to 100, and the Trump box all the way down to 0. 25% of Biden voters give BLM exactly 100, and 46% of Trump voters give it exactly 0. Respondents cannot report anything warmer than 100 or colder than 0, so the scale caps how much spread we can observe at those ends. This is called a ceiling (or floor) effect. We call this censured data. It is one more reason to look at the picture rather than just the numbers.
Finally, compare this to the police thermometer from the slides. There, Trump voters were far more homogeneous than Biden voters (SD 16.7 against 24.4)