Publications by Anthony B. Masters

ONS Weekly Death Registrations Figure 3

14.04.2021

Purpose The goal of this code is to emulate the Figure 3 graph from the Office for National Statistics weekly death registrations reports. The graph shows a stacked bar graph for two different types of deaths, along with a horizontal line for the past average. The report for the week ending 2nd April 2021 is available on the ONS website. This cod...

880 sym R (4976 sym/9 pcs) 1 img

ONS Mortality Rates II

24.03.2021

Purpose The purpose of this R code is to analyse changes in the age-standardised mortality rate in England and Wales. The mortality rate statistics come from the Office for National Statistics. These figures are based on death registrations by registration date. In this code, I use Prof Kay’s ggdist package and Thomas Lin Pederson’s patchwork...

1446 sym R (6320 sym/15 pcs) 2 img

Diagnostic Testing - Stochastic

16.03.2021

Purpose The purpose of this R Markdown document is to show how much the positive and negative predictive values vary. The scenario is for a test where: the prevalence is 0.04%, the false-positive rate is 0.03%, and the false-negative rate is 50%. The main output is a graph, using Prof Matthew Kay’s ggdist package and Thomas Lin Peterson’s pat...

1317 sym R (4368 sym/15 pcs) 1 img

PHE Weekly COVID-19 and Flu Small Multiples

03.03.2021

R Markdown This R code generates a small multiples graph, showing COVID-19 and influenza hospital admission rates by week in English regions. The statistics come from SARI Watch, and are published by Public Health England. This graph shows an alternate version of Figure 38 in the National flu and COVID-19 surveillance report for week 8. The stati...

770 sym R (2428 sym/7 pcs) 1 img

Savanta ComRes Scottish Independence Polling

15.03.2021

Purpose The purpose of this R code is to produce a graph, showing Scottish independence polling results by weighting schema. Survey statistics can be drawn from the Savanta ComRes polling archive. All of the included surveys ask a question on Scottish independence, worded: “If there were a referendum on Scottish independence tomorrow with the q...

1260 sym R (2833 sym/6 pcs) 1 img

Sweden Mortality 2020

02.04.2021

Purpose The purpose of this R Markdown document is to produce an Office for National Statistics-style for mortality in another country. The example country I chose was Sweden, from the data-set collated by Our World in Data. The ONS weekly death registration reports are available on the ONS website. Packages and themes First, install the package...

937 sym R (4315 sym/11 pcs) 1 img

Birthday Problem

25.05.2021

Purpose This R code simulates probabilities of two random people sharing a birthday (a birthday pair). This is shown using ONS birth statistics and for the theoretical probability (with simplifying assumptions). Packages and Themes First, download the packages we need: library(tidyverse) library(scales) library(readxl) library(lubridate) Second,...

1067 sym R (4508 sym/11 pcs) 2 img

Pub Industry Turnover Losses Estimates

19.05.2021

Purpose The purpose of this R code is to show uncertainty in model estimates of UK pub industry losses in 2020. The distributional assumptions are my own. Packages and themes First, we install the packages we need: library(tidyverse) library(ggdist) library(scales) library(patchwork) Next, we set the plotting theme. theme_clean4 <- theme_bw(base...

951 sym R (3468 sym/10 pcs) 1 img

Senedd 2021 Vote Intention Estimates

05.05.2021

Purpose The purpose of this R code is to create mosaic graphs, showing party vote intention estimates for each company. The election is for the Senedd (Welsh Parliament), taking place on Thursday 6th May 2021. Packages and themes First, install the packages we need: library(tidyverse) library(readxl) library(lubridate) Next, I set the plotting t...

670 sym R (4986 sym/10 pcs) 2 img

Google Trends Data - 2021-04-28

28.04.2021

Purpose The purpose of this R code is to produce a graph showing trends in three search terms. The monthly statistics are for the United States, drawn from Google Trends. Packages and Themes First, install the packages we need: library(tidyverse) library(readxl) library(lubridate) Next, I set the plotting theme. theme_clean4 <- theme_bw(base_fam...

682 sym R (2875 sym/8 pcs) 1 img