Publications by Higher Order Functions
10 PRINT mazes with ggplot2
There is a celebrated Commodore 64 program that randomly prints outs / and \ characters and fills the screen with neat-looking maze designs. It is just one line of code, but there is a whole book written about it. 10 PRINT CHR$(205.5+RND(1)); : GOTO 10 Screenshots of the 10 PRINT program in action. Images taken from the 10 PRINT book. The basic...
4058 sym R (6297 sym/15 pcs) 32 img
sample_n_of(): a useful helper function
Here’s the problem: I have some data with nested time series. Lots of them. It’s like there’s many, many little datasets inside my data. There are too many groups to plot all of the time series at once, so I just want to preview a handful of them. For a working example, suppose we want to visualize the top 50 American female baby names over...
3962 sym R (6343 sym/17 pcs) 4 img
Anatomy of a logistic growth curve
In this post, I walk through the code I used to make a nice diagram illustrating the parameters in a logistic growth curve. I made this figure for a conference submission. I had a tight word limit (600 words) and a complicated statistical method (Bayesian nonlinear mixed effects beta regression), so I wanted to use a diagram to carry some of the ...
7839 sym R (4767 sym/11 pcs) 18 img
ICC Bot comes online
I am happy to announce the release of ICC Bot, an app for computing interrater reliability scores using the intraclass correlation coefficient (ICC). A screenshot of ICC Bot, an interactive app for computing intraclass correlation coefficients. The ICC statistic appears in repeated measures or multilevel modeling literature as a way to qu...
9581 sym R (2914 sym/8 pcs) 4 img
Another mixed effects model visualization
Last week, I presented an analysis on the longitudinal development of intelligibility in children with cerebral palsy—that is, how well do strangers understand these children’s speech from 2 to 8 years old. My analysis used a Bayesian nonlinear mixed effects Beta regression model. If some models are livestock and some are pets, this model is...
7441 sym R (8240 sym/17 pcs) 22 img
Bayes’ theorem in three panels
In my last post, I walked through an intuition-building visualization I created to describe mixed-effects models for a nonspecialist audience. For that presentation, I also created an analogous visualization to introduce Bayes’ Theorem, so here I will walk through that figure.. As in the earlier post, let’s start by looking at the visualizati...
6621 sym R (3702 sym/8 pcs) 14 img
Q-Q Plots and Worm Plots from Scratch
One of the things I have come to appreciate is how programming is a great way to learn statistics. My eyes will glaze over at a series of equations in a derivation, but ask me to program the procedure and I’ll never forget how it works. This post will be one of those exercises where we program a statistical tool—a Q-Q plot (plus its friend th...
12255 sym R (9195 sym/26 pcs) 28 img
Lists are my secret weapon for reporting stats with knitr
I am going to describe my favorite knitr trick: Using lists to simplify inline reporting. Trick might not do it justice. I consider this a best practice for working with knitr. Plug it in Inline reporting lets you insert R expressions inside of markdown text. Those expressions are evaluated and their results are plugged in as text. The following ...
5067 sym R (15794 sym/20 pcs)
Random effects and penalized splines are the same thing
For a long time, I’ve been curious about something. It is a truth I’ve seen casually dropped in textbooks, package documentation, and tweets: random effects and penalized smoothing splines are the same thing. It sounds so profound and enlightened. What does it mean? How are they the same? What deep statistical gnosis was I missing out on? I ...
18512 sym R (27879 sym/27 pcs) 28 img
Think of `&&` as a stricter `&`
In programming languages, we find logical operators for and and or. In fact, Python uses the actual words and and or for these operators. # Python via the reticulate package x = True y = False x and y #> False x or y #> True In Javascript, we see && for and and || for or instead. // Javascript via `engine = "node"` in knitr let x = true; let y =...
7166 sym R (6355 sym/18 pcs)