RSSAmplifier

Blog

Andrew Heiss's blog

Andrew Heiss's blog

andrewheiss.comRSS feed ↗60 posts

Latest posts

Generating universes within universes with a single seed

See how one call to set.seed() in R creates an entire predetermined universe of pseudorandom numbers

How to automatically convert TikZ images to SVG with Quarto

Make Quarto convert TikZ graphics to SVG files when rendering to non-LaTeX outputs like HTML, Word, and Typst

How to make your data analysis life easier using Positron, Raycast, and Espanso

Links and resources from my time on Posit’s Data Science Lab in January 2026

How to open a folder as a Positron project with macOS Quick Actions

Add a Quick Action workflow so that you can right click on a folder in Finder to open it in Positron.

How to use Positron’s Connections Pane with DuckDB

Positron’s Connections Pane makes it really convenient to work with most types of databases—here’s how to connect to lighting fast DuckDB files.

Use Positron to run R inside a Docker image through SSH

Running R in Docker containers is great for reproducible projects, but writing and running code in the container can be a hassle. Use Positron to SSH into local Docker containers instead!

Open files in external programs with Positron or Visual Studio Code

Positron is great for code, but macOS has better programs specifically for writing with Markdown. Quickly open a Quarto file in an external program with tasks.

How to use a histogram as a legend in {ggplot2}

Land isn’t unemployed—people are. Here’s how to use R, {ggplot2}, {sf}, and {patchwork} to create a histogram legend in a choropleth map to better see the distribution of values.

How to move Crimea from Russia to Ukraine in maps with R

Natural Earth’s de facto on-the-ground policy conflicts with de jure boundaries. Use {sf} and R to relocate parts of country shapes.

Using USAID data to make fancy world maps with Observable Plot

Manipulate geographic data, change projections, get live data from a database, and make interactive plots with Observable JS

Guide to comparing sample and population proportions with CPS data, both classically and Bayesianly

Download CPS demographic data from IPUMS and use R and {brms} to calculate differences between sample and national proportions with Bayesian ROPE-based inference

Apple Music Wrapped with R

Use R to parse Apple Music XML files and create your own Spotify Wrapped-like stats

Guide to generating and rendering computational markdown content programmatically with Quarto

Learn how to use knitr::knit() in inline chunks to correctly render auto-generated R and markdown content in Quarto documents

Fun with Positron

Combine the best of RStudio and Visual Studio Code in Posit’s new Positron IDE

Calculating the proportion of US state borders that are coastlines

Measuring coastlines is hard and causes fractal paradoxes, but we can use R and {sf} to try!

Calculating birthday probabilities with R instead of math

Probability math is hard. Use brute force simulation to find the probability that a household has a cluster of birthdays.

Visualizing {dplyr}’s mutate(), summarize(), group_by(), and ungroup() with animations

Visually explore how {dplyr}’s more complex core functions work together to wrangle data

Demystifying causal inference estimands: ATE, ATT, and ATU

Explore why we care about the ATE, ATT, and ATU and figure out how to calculate them with observational data

DIY API with Make and {plumber}

Use Make and {plumber} to create your own API and show live data in Quarto with R and Observable JS

How to create separate bibliographies in a Quarto document

Use multibib and Quarto to create separate bibliographies for a document and an appendix

Guide to understanding the intuition behind the Dirichlet distribution

Learn about the Dirichlet distribution and explore how it’s just a fancier version of the Beta distribution

Manually generate predicted values for logistic regression with matrix multiplication in R

This is like basic stats stuff, but I can never remember how to do it—here’s how to use matrix multiplication to replicate the results of predict()

The ultimate practical guide to multilevel multinomial conjoint analysis with R

Learn how to use R, {brms}, {marginaleffects}, and {tidybayes} to analyze discrete choice conjoint data with fully specified hierarchical multilevel multinomial models

How to fill maps with density gradients with R, {ggplot2}, and {sf}

Fix overplotted points on maps by creating bins or filled density gradients using R, {ggplot2}, and {sf}

The ultimate practical guide to conjoint analysis with R

Learn how to use R, {brms}, and {marginaleffects} to analyze conjoint data and find causal and descriptive quantities of interest, both frequentistly and Bayesianly

Road trip analysis! How to use and play with Google Location History in R

Learn how to use R to load and clean and play with all the location history data Google keeps about you and look at some neat plots and tables about our 5,000-mile summer road trip along the way

How to make fancy road trip maps with R and OpenStreetMap

Use R to get geocoded location and routing data from OpenStreetMap and explore our family’s impending 5,000 mile road trip around the USA

A guide to Bayesian proportion tests with R and {brms}

Use R, Stan, and {brms} to calculate differences between categorical proportions in a principled Bayesian way

Making Middle Earth maps with R

Explore Tolkien’s Middle Earth with R-based GIS tools, including {ggplot2} and {sf}

How old was Aragorn in regular human years?

Use statistical simulation and a hidden table of Númenórean ages from Tolkien’s unpublished works to convert Aragorn’s Dúnedan years to actual human years

One Simple Trick™ to create inline bibliography entries with Markdown and pandoc

By default, pandoc doesn’t include full bibliographic references inline in documents, but with one tweak to a CSL file, you can create syllabus-like lists of citations with full references

How to migrate from BibDesk to Zotero for pandoc-based writing

Tips, tricks, and rationale for converting from a single big BibTeX file to a Zotero database

How to use natural and base 10 log scales in ggplot2

Use the {scales} R package to automatically adjust and format x- and y-axis scales to use log base 10 and natural log values

Marginal and conditional effects for GLMMs with {marginaleffects}

Use the {marginaleffects} package to calculate tricky and nuanced marginal and conditional effects in generalized linear mixed models

Visualizing the differences between Bayesian posterior predictions, linear predictions, and the expectation of posterior predictions

A guide to different types of Bayesian posterior distributions and the nuances of posterior_predict, posterior_epred, and posterior_linpred

Quick and easy ways to deal with long labels in ggplot2

Explore different manual and automatic ways to rotate, dodge, recode, break up, and otherwise deal with long axis labels with ggplot2

Marginalia: A guide to figuring out what the heck marginal effects, marginal slopes, average marginal effects, marginal effects at the mean, and all these other marginal things are

Define what marginal effects even are, and then explore the subtle differences between average marginal effects, marginal effects at the mean, and marginal effects at representative values with the marginaleffects and emmeans R packages

A guide to modeling outcomes that have lots of zeros with Bayesian hurdle lognormal and hurdle Gaussian regression models

Create, manipulate, understand, analyze, interpret, and plot Bayesian hurdle regression models (and a custom hurdle Gaussian model!) using R, the tidyverse, emmeans, brms, and Stan

How to create a(n almost) fully Bayesian outcome model with inverse probability weights

Use a posterior distribution of inverse probability weights in a Bayesian outcome model to conduct (nearly) fully Bayesian causal inference with R, brms, and Stan

How to use Bayesian propensity scores and inverse probability weights

For mathematical and philosophical reasons, propensity scores and inverse probability weights don’t work in Bayesian inference. But never fear! There’s still a way to do it!

A guide to working with country-year panel data and Bayesian multilevel models

How to use multilevel models with R and brms to work with country-year panel data.

A guide to correctly calculating posterior predictions and average marginal effects with multilievel Bayesian models

How to calculate grand means, conditional group means, and hypothetical group means of posterior predictions from multilevel brms models.

A guide to modeling proportions with Bayesian beta and zero-inflated beta regression models

Everything you ever wanted to know about beta regression! Use R and brms to correctly model proportion data, and learn all about the beta distribution along the way.

Do-calculus adventures! Exploring the three rules of do-calculus in plain language and deriving the backdoor adjustment formula by hand

Use R to explore the three rules of do-calculus in plain language and derive the backdoor adjustment formula by hand

How to automatically convert TikZ images to SVG (with fonts!) from knitr

Make knitr and R Markdown convert TikZ graphics to font-embedded SVG files when knitting to HTML

Exploring Pamela Jakiela’s simple TWFE diagnostics with R

Use R to explore possible biases that come from differential treatment timing in two-way fixed effects (TWFE) regression models

Exploring R² and regression variance with Euler/Venn diagrams

Use Venn diagrams to visualize the proportion of an outcome explained by a regression model

AFC Richmond / Ted Lasso cross stitch pattern

Make your own Ted Lasso AFC Richmond crest cross stitch with a free pattern and an Illustrator template

Hex sticker/logo cross stitch pattern

Make your own data science hex logo cross stitch with a free pattern and an Illustrator template

Bayesian (cross stitch) sampler

Make your own Bayesian cross stitch sampler with a free pattern of Bayes Theorem and the accompanying Illustrator template