ggplot() +
stat_ecdf(
data = positive_damage,
aes(prop_usd, color = "Fn: empirical"),
geom = "step",
linewidth = 1
) +
geom_line(
data = normal_reference,
aes(prop_usd, cdf, color = "F0: fitted normal"),
linewidth = 1,
linetype = "dashed"
) +
geom_segment(
data = ks_mark,
aes(
x = prop_usd,
xend = prop_usd,
y = empirical_cdf,
yend = fitted_cdf
),
inherit.aes = FALSE,
color = "#b31b34",
linewidth = 1.6
) +
geom_point(
data = ks_mark,
aes(x = prop_usd, y = empirical_cdf),
inherit.aes = FALSE,
color = "#b31b34",
size = 2.7
) +
geom_point(
data = ks_mark,
aes(x = prop_usd, y = fitted_cdf),
inherit.aes = FALSE,
color = "#b31b34",
size = 2.7
) +
geom_text(
data = ks_mark,
aes(x = label_x, y = label_y, label = label),
inherit.aes = FALSE,
color = "#b31b34",
fontface = "bold",
hjust = 0,
size = 4.2
) +
scale_x_log10(
breaks = c(1e3, 1e6, 1e9),
labels = c("$1K", "$1M", "$1B")
) +
scale_y_continuous(labels = percent) +
scale_color_manual(
values = c("Fn: empirical" = deep_gold, "F0: fitted normal" = blue_gray),
breaks = c("Fn: empirical", "F0: fitted normal")
) +
labs(
title = "The largest fitted-normal gap occurs at $5,000",
subtitle = "Normal fit to log10(property damage) using the sample mean and SD",
x = "Reported property damage",
y = "Share at or below amount",
color = NULL
)