This code wrangles data straight from an online file on the NHS England website, producing graphs with population estimates and vaccine coverage by age group.
The purpose of this R code is to show total beds occupied by confirmed Covid-19 patients, by primary admission reason. This is given in a data file on the NHS England website.
The purpose of this R code is to show the revision to vaccine coverage (by dose) for the adult population in England. This is drawn from two sheets downloaded from the Public Health England Coronavirus dashboard.
The purpose of this R code is to draw data from the online UK Life Table showing numbers dying at exact ages (dx). Once drawn, we can create a graph showing the expected numbers dying at single years of age from a synthetic cohort, by UK nation.
The purpose of this R code is to produce a graph showing Covid-19 vaccine coverage in England by age group and population estimates. The goal is to wrangle the data directly from the NHS England online spreadsheet into that graph.
The purpose of this R code is to show vaccine effectiveness in an illustrative at-risk population. That shows the counter-intuitive result with sufficiently high coverage, most deaths from the disease will be among those vaccinated (assuming 94% protection).
This R Markdown looks at the effect of using different spans for local regression (Loess) curves, for UK/GB general election vote intention polls.
This R code compares different uncertainty intervals for an A/B test, and produces a 'dots' posterior distribution graph.
This R code simulates the birthday problem with ONS birth statistics from 1995 to 2014. The results are similar to the simplified standard calculation.
This code makes distributional assumptions, and then simulates potential values of UK public houses in 2020. Those simulations are presented as a dot plot.
This code creates mosaic graphs, showing vote intention estimates by polling company. This is for the Senedd 2021 elections.
This code produces a graph showing Google search volume indices for three different search queries.
This code emulates the Figure 3 graph from the Office for National Statistics weekly death registration report.
The purpose of this document is to produce graphs with 10,000 and 100,000 dots. This is to help show the odds of one in 10,000 and one in 100,000.
I produce an ONS-style for Swedish mortality in 2020. Statistics Sweden excludes deaths with unknown dates of occurrence. The average of week 52 is used for week 53.
This analysis looks at changes in age-standardised mortality rates in England and Wales over time. There are two graphs, one showing the rates and changes, and the other is a dot-plot of changes.
The purpose of this R code is to show much precision and negative predictive values vary. This is for a binary diagnostic test, where there is low prevalence.
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.
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.
The purpose of this code is to draw a employment time series from the ONS beta API. I used that data frame to create a graph of the UK employment rate for people aged 16-64.
This code creates two graphs, concerning death registrations and mortality rates in England and Wales. The graphs cover 1900 to 2020 (provisional). Thomas Lin Pederson's patchwork package is used to join two sub-graphs together.
The purpose of this code is to create graphs showing COVID-19 admissions and patients over time. This code will use Public Health England's R package ukcovid19.
The purpose of this code is to create graphs comparing two different COVID-19 death measures by date of death. The first measure is death registrations from the Office for National Statistics. This analysis uses the data file for registrations up to 15th January 2021. The second measure is confirmed deaths from Public Health England (who report for the UK on their dashboard). Here, rather than using a prepared file, I draw the figures straight from the API.
The purpose of this code is to compare Base R and tidyverse code for data manipulation.
This document produces two animated graphs. These graphs show how the ONS COVID-19 positivity and incidence models in England develop over time. The positivity model is more stable than the incidence model.
The code creates an animated graph of ONS modelled incidence rates of COVID-19 in England. The graph shows how the modelled estimates are revised over time.
This document calculates the probability of a numerical sequence occurring at least once in many draws. The calculations are for the South African PowerBall lottery.
This R Markdown document uses the ukcovid19 package from Public Health England to create a graph. This package could underlie repeatable analyses or data visualisations.
This page looks at Newcomb-Benford distributions and 2020 US Presidential election results. The graphs show why we would not expect conformity to Benford's Law of vote counts in Chicago precincts.
The R Markdown document simulates populations. We then calculate the standard errors for systematic and simple random sampling. These standard errors are then compared in a scatter graph.
This page creates a heatmap of lab-confirmed SARS-CoV-2 cases in England per 100,000 people in each age group. This is from Public Health England statistics.
This document illustrates the central estimate of true and false positive results against prevalence.
This document looks at a Bayesian analysis of an A/B test. Using uniform priors, I use numerical methods to calculate the posterior distribution and produce a graph. I also compare the mean and interval estimate to an approximation.
This R Markdown document creates an automated table. The inputs are UK vote intention polls. The output is a table of estimated house effects for each polling company.
This R Markdown document produces generalised additive models (using the mgcv package), in order to estimate polling company house effects. The code also makes a graph showing vote intention estimates over time, by company.
This document produces three graphs: for England, Wales, and Scotland. The graphs compare deaths involving COVID-19 for statistics offices (ONS and NRS) and public health agencies (PHE, PHW, and PHS).
This R Markdown document creates two graphs, with annotations. The graphs compare deaths with COVID-19 from Public Health England and Public Health Wales to the Office for National Statistics. The ONS death certificate mentions were drawn from a weekly occurrence reportPHE and PHW statistics comes from the Public Health England Coronavirus Staging Dashboard.
This R Markdown page creates a graph by different weights for the UK's hypothetical EU membership referendum question.
This R Markdown document shows how to make a graph of confirmed SARS-CoV-2 cases in Wiltshire.
This R Markdown document creates graphs of Google search trends. The trends are shown as a rounded index, where 100 is the highest volume. We can draw Google search indices from the Google Trends tool.
This code creates a function which simulates forest fires. The simulations are run across lattice graphs with added edges.
This article looks at weekly death registrations in England and Wales. The code produces three graphs which show trends in death registrations.
This document produces counts and graphs about constituency majorities in the 2017 General Election.
This document calculates doubling times (over seven days) for confirmed COVID-19 deaths. The graph shows doubling times for five selected countries.
This document creates to compare linear and logarithmic scales.
Using three illustrative examples, this document shows the importance of prevalence, false positive and false negative rates.
This document uses functions to create mortgage repayment tables. The document then shows the effect of different over-payment schedules.
This R Markdown document shows the code for creating static and animated graphs. The aim is to show a different version of the Law of Large Numbers, applying it to dice rolls and their cumulative sum.
This R code creates graphs showing the errors (net by party and three party absolute) of each constituency poll over time, in the 2019 UK General Election.
This document creates a graph showing different p-value calculations for pairs of proportions, under different modelling assumptions.
The code shows how to create four graphs for General Election vote share: in England, Scotland, Wales, and England plus Wales.
This document contains R code for graphs showing the BBC's weekly reach and viewing share.
This document shows how the declared aggregate vote share changes between the 2017 and 2019 General Elections developed on election night.
This document contains code on forecasting the proportion of Firsts in 2029/30, using HESA statistics.
This graph shows UK vote shares in General Elections from 1918 to 2019.
This code is to create a graph showing exit poll in the past six General Elections.
This code creates two graphs for an illustrative election -- as an example of the ecological fallacy.
This article provides code for three graphs, illustrating the problem of false recall in social research.
This article creates a graph which compares an actual polling average to self-selecting Facebook surveys, on the subject of an EU membership referendum.
This document looks at creating a graph of the 2017 General Election result in Chippenham.
This article uses geom_dumbbell to recreate a graph showing changes in moral attitudes over the past 30 years. Another article recreating a Pew Research Center graph may be read here: https://rud.is/b/2016/04/17/ggplot2-exercising-with-ggalt-dumbbells/
This article shows the usage of various functions in the survey package, with dummy survey data.
In an attempt to replicate a graph in the Byline Times, I use the FCA public disclosures data-set which shows large net short position changes.
This document looks how to create a graph of vegans and complete vegetarians from the first five waves of the Food and You survey. This survey has most recently covered adults in England, Wales and Northern Ireland, and the fifth wave was conducted by NatCen and NISRA.
This code produces a Sankey diagram in the GoogleVis package, using the central estimates from a recent Opinium internet panel survey.
This is a graph showing central estimates from the Number Cruncher Politics poll of Brecon & Radnorshire. The graph uses facet wraps to show both the vote intention share estimate and the implied change from the 2017 General Election.
This article runs statistical tests (exact Binomial and a similar Bayesian test). Additionally, I create a graph showing the number of days with specified events by football season (August to May).
This graph shows the results of one question in the ComRes internet panel survey of 1,015 fathers, conducted between 29th May and 4th June 2019. The survey was commissioned by campaign group Fathers4Justice.
Under the assumption of a simple random sample, the code creates a graph for margins of sampling error at different proportions and sample sizes (for 95% confidence intervals).
This document will contain all relevant R code for my poster about British MPs on Twitter.
This document shows the steps used to create a summary table and graphs for council tax measures by local authority (overall) control. This is to be compared against claims made by the Conservative and Labour parties.
This document shows how to connect the A50 revocation petition data to the BES 2017 Constituency results dataset (for GB constituencies). Two scatter graphs are drawn, comparing the Level 4 qualification share and Remain estimate against the signature shares by constituency.
This publication contains the R code for graphs on various UK labour market measures.
This documents look at different ways of representing polling data before and after the UK's European Union membership referendum, including introducing a discontinuity in the Loess regression curves at the referendum date.