Scores for all assignments so far will be on D2L soon
Project 2 groups have been announced, repos should be assigned
Take a note of the deadlines for the rest of the semester
Setup
# load packagesif(!require(pacman))install.packages("pacman")pacman::p_load(countdown, tidymodels, tidyverse, colorspace, cowplot, waffle, distributional, emmeans, gapminder, ggdist, margins, ggtext, ggpubr)# for github packages (make sure to use #| output: false)pacman::p_load_gh("wilkelab/ungeviz")# set theme for ggplot2ggplot2::theme_set(ggplot2::theme_minimal(base_size =14, base_family ="Myriad Pro"))# set width of code outputoptions(width =65)# set figure parameters for knitrknitr::opts_chunk$set(fig.width =7, # 7" widthfig.asp =0.618, # the golden ratiofig.retina =3, # dpi multiplier for displaying HTML output on retinafig.align ="center", # center align figuresdpi =300# higher dpi, sharper image)
Uncertainty
Playing
Image by Wikimedia user Jahobr, released into the public domain.
90% chance of winning is nowhere near a certain win
Uncertainty in probability
Probability distributions
Whats the probability that the blue party wins the election?
Probability distributions
Uncertainty of point estimates
Uncertainty of point estimates
Uncertainty of point estimates
Frequentist interpretation of a confidence interval
Everest
everest <-read_csv("data/everest.csv")
everest
# A tibble: 21,813 × 21
expedition_id member_id peak_id peak_name year season sex
<chr> <chr> <chr> <chr> <dbl> <chr> <chr>
1 EVER63101 EVER63101-… EVER Everest 1963 Spring M
2 EVER63101 EVER63101-… EVER Everest 1963 Spring M
3 EVER63101 EVER63101-… EVER Everest 1963 Spring M
4 EVER63101 EVER63101-… EVER Everest 1963 Spring M
5 EVER63101 EVER63101-… EVER Everest 1963 Spring M
6 EVER63101 EVER63101-… EVER Everest 1963 Spring M
7 EVER63101 EVER63101-… EVER Everest 1963 Spring M
8 EVER63101 EVER63101-… EVER Everest 1963 Spring M
9 EVER63101 EVER63101-… EVER Everest 1963 Spring M
10 EVER63101 EVER63101-… EVER Everest 1963 Spring M
# ℹ 21,803 more rows
# ℹ 14 more variables: age <dbl>, citizenship <chr>,
# expedition_role <chr>, hired <lgl>, highpoint_metres <dbl>,
# success <lgl>, solo <lgl>, oxygen_used <lgl>, died <lgl>,
# death_cause <chr>, death_height_metres <dbl>, injured <lgl>,
# injury_type <chr>, injury_height_metres <dbl>
Highest point reached on Everest in 2019
Includes only climbers and expedition members who did not summit
Marginal effects: Height reached on Everest
Average height reached relative to: a male climber who climbed with oxygen, summited, and survived
Marginal effects: Height reached on Everest
Other visualization options: half-eye
Marginal effects: Height reached on Everest
Other visualization options: gradient interval
Marginal effects: Height reached on Everest
Other visualization options: quantile dotplot
Marginal effects: Height reached on Everest
Other visualization options: quantile dotplot
Marginal effects: Height reached on Everest
Other visualization options: quantile dotplot
Making a plot with error bars in R
Example: Relationship between life expectancy and GDP per capita
Making a plot with error bars in R
Example: Relationship between life expectancy and GDP per capita
Gapminder
See gapminder.org for fantastic visualizations and up-to-date data
gapminder
# A tibble: 1,704 × 6
country continent year lifeExp pop gdpPercap
<fct> <fct> <int> <dbl> <int> <dbl>
1 Afghanistan Asia 1952 28.8 8425333 779.
2 Afghanistan Asia 1957 30.3 9240934 821.
3 Afghanistan Asia 1962 32.0 10267083 853.
4 Afghanistan Asia 1967 34.0 11537966 836.
5 Afghanistan Asia 1972 36.1 13079460 740.
6 Afghanistan Asia 1977 38.4 14880372 786.
7 Afghanistan Asia 1982 39.9 12881816 978.
8 Afghanistan Asia 1987 40.8 13867957 852.
9 Afghanistan Asia 1992 41.7 16317921 649.
10 Afghanistan Asia 1997 41.8 22227415 635.
# ℹ 1,694 more rows