Skip to content

Instantly share code, notes, and snippets.

@richardbeare
richardbeare / smoothing_random_effect.md
Last active July 7, 2023 07:01
ggplot gam smoothing with random effects

Tricks for plotting formant data with gam smoothing

Speech data sets typically contain multiple repetitions of the same speech sound, each sampled at multiple time points. The samples within a given repetition are thus not independent and smoothing procedures should take this into account. One way of doing this with generalized additive models (gams) is via a random effect. However, random effects are not included when performing smoothing with ggplot2 using default options. This gist illustrates some tricks for incuding random effects in ggplot smoothing.

The methods below have been used in the following papers: