Publications by Higher Order Functions

I don’t know Fisher’s exact test, but I know Stan

15.05.2017

A few days ago, I watched a terrific lecture by Bob Carpenter on Bayesian models. He started with a Bayesian approach to Fisher’s exact test. I had never heard of this classical procedure, so I was curious to play with the example. In this post, I use the same data that he used in the lecture and in an earlier, pre-Stan blog post. I show how I ...

9344 sym R (8279 sym/14 pcs) 10 img 1 tbl

New package polypoly (helper functions for orthogonal polynomials)

29.05.2017

Last week, I released a new package called polypoly to CRAN. It wraps up some common tasks for dealing with orthogonal polynomials into a single package. The README shows off the main functionality, as well as the neat “logo” I made for the package. In this post, I use the package on some word recognition data. Demo: Growth curve analysis I...

5419 sym R (7635 sym/13 pcs) 12 img

Plotting partial pooling in mixed-effects models

21.06.2017

In this post, I demonstrate a few techniques for plotting information from a relatively simple mixed-effects model fit in R. These plots can help us develop intuitions about what these models are doing and what “partial pooling” means. The sleepstudy dataset For these examples, I’m going to use the sleepstudy dataset from the lme4 package....

14353 sym R (14112 sym/22 pcs) 22 img

A tour of the tibble package

09.07.2017

Dataframes are used in R to hold tabular data. Think of the prototypical spreadsheet or database table: a grid of data arranged into rows and columns. That’s a dataframe. The tibble R package provides a fresh take on dataframes to fix some longstanding annoyances with them. For example, printing a large tibble shows just the first 10 rows ins...

5989 sym R (10612 sym/15 pcs)

set_na_where(): a nonstandard evaluation use case

14.08.2017

In this post, I describe a recent case where I used rlang’s tidy evaluation system to do some data-cleaning. This example is not particularly involved, but it demonstrates is a basic but powerful idea: That we can capture the expressions that a user writes, pass them around as data, and make some :dizzy: magic :sparkles: happen. This techniqu...

5773 sym R (5794 sym/15 pcs) 4 img

Simplifying ggplot2 code by doing nothing

10.10.2017

Recently, I joined the development team for bayesplot, an R package by the Stan team for plotting Bayesian models. Because visualizing Bayesian models in ggplot2 is a recurring topic here, it was a natural fit. So from time to time, I’ll post about some programming techniques and new features we develop in the bayesplot package. For this post, ...

6676 sym R (6874 sym/13 pcs) 22 img

Secret Santa is a graph traversal problem

28.11.2017

Last week at Thanksgiving, my family drew names from a hat for our annual game of Secret Santa. Actually, it wasn’t a hat but you know what I mean. (Now that I think about it, I don’t think I’ve ever seen names drawn from a literal hat before!) In our family, the rules of Secret Santa are pretty simple: The players’ names are put in “a...

11761 sym R (8030 sym/15 pcs)

Using nonstandard evaluation to simulate a register machine

05.01.2018

I recently completed all 25 days of Advent of Code 2017, an annual series of recreational programming puzzles. Each day describes a programming puzzle and illustrates a handful of simple examples of the problem. The puzzle then requires the participant to solve a much, much larger form of the problem. For five or so of the puzzles, I used nonstan...

1296 sym R (75 sym/1 pcs)

Recode values with character subsetting

09.01.2018

Do you ever have to recode many values at once? It’s a frequent chore when preparing data. For example, suppose we had to replace state abbreviations with the full names: abbs <- c("AL", "AK", "AZ", "AZ", "WI", "WS") You could write several ifelse() statements. ifelse(abbs == "AL", "Alabama", ifelse(abbs == "AK", "Alaska", ...

2194 sym R (2333 sym/11 pcs)

Ridgelines in bayesplot 1.5.0

02.04.2018

At the end of March, Jonah Gabry and I released bayesplot 1.5.0. The major additions to the package were visualizations using ridgelines and a new plot for PIT diagnostics from LOO validation. I don’t know what that LOO PIT thing is yet, so I’ll talk about how ridgelines have been incorporated into bayesplot instead. Behind the scenes of mcmc...

3846 sym R (3737 sym/6 pcs) 12 img