Supplementary Materials for the paper:

Jacolien van Rij, Petra Hendriks, Hedderik van Rijn, R. Harald Baayen, Simon N. Wood: Analyzing the time course of pupillometric data. Accepted with minor revisions for Trends in Hearing Science. November, 2018.

Also available on GitLab.


\(\leftarrow\) previous | home | next \(\rightarrow\)

Simulations

Simulation I: Variation in amplitude

Simulation II: Adding random noise

Simulation II (b): Reduced variation in amplitude

Simulation III: Modeling individual trends


Setup

Load packages for analysis and visualization:

## Loading required package: nlme
## This is mgcv 1.8-24. For overview type 'help("mgcv-package")'.
## Loading required package: plotfunctions
## Loaded package itsadug 2.3 (see 'help("itsadug")' ).

Function for simulations:

The sineWave function can modify sine waves in different ways:

  1. Changes the amplitude

  2. Changes the latencies of the peaks, stretching the signal

  3. Adds a linear slope to the sine wave, tilting the signal around x=0

The red lines in the example plots below show manipulations of parameters a, b, and c respectively.

Note: In the simulations below only parameter a (amplitude) is manipulated for illustration purposes. However, we do not assume that the pupil dilation trials only differ in amplitude. As Figure 1 in the paper indicates, there is huge variation between individual trials in amplitude, number of peaks, peak latency, and slope.

Simulation I: Variation in amplitude

[up \(\uparrow\)]

Visualization of all simulated data:

Run simple GAM model to capture average trend:

## 
## Family: gaussian 
## Link function: identity 
## 
## Formula:
## y1 ~ s(x)
## 
## Parametric coefficients:
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.589e-16  1.108e-03       0        1
## 
## Approximate significance of smooth terms:
##        edf Ref.df     F p-value    
## s(x) 8.987      9 46163  <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## R-sq.(adj) =  0.943   Deviance explained = 94.3%
## fREML = -8028.7  Scale est. = 0.030701  n = 25000

Below we have plotted 10 randomly selected modified sine waves (of the 250 in total), and the model fit for the sine waves.

Results: Autocorrelation in data Simulation I (Figure 10, top row)

Selection of 10 random trials, and the residuals and fitted values of the GAM model:

Right panel

Autocorrelation of the model’s residuals (all 250 sine waves) for each lag (x-axis).

(See the results of Simulation II for the middle row of Figure 10.)


Simulation II: Adding random noise

[up \(\uparrow\)]

When independent noise ( \(u \sim \mathcal{N}(0, .25)\) )was added to the same simulation data as in Simulation I, the autocorrelation was reduced in a GAM with exactly the same model specification.

## 
## Family: gaussian 
## Link function: identity 
## 
## Formula:
## y2 ~ s(x)
## 
## Parametric coefficients:
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0004277  0.0012671   0.338    0.736
## 
## Approximate significance of smooth terms:
##        edf Ref.df     F p-value    
## s(x) 8.982      9 35318  <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## R-sq.(adj) =  0.927   Deviance explained = 92.7%
## fREML = -4679.5  Scale est. = 0.040138  n = 25000

Below we have plotted the same 10 randomly selected modified sine waves (of the 250 in total), and the model fit for the sine waves.

Results: Autocorrelation in data Simulation II (Figure 10, middle row)

Selection of 10 random trials, and the residuals and fitted values of the GAM model:

Right panel

Autocorrelation of the model’s residuals (all 250 sine waves) for each lag (x-axis).

(See the results of Simulation III for the bottom row of Figure 10.)


Simulation II (b): Reduced variation in amplitude

[up \(\uparrow\)]

When a new data set is created with less variation in amplitudes between the individual trials (\(a \sim \mathcal{N}(1, .10)\)), but the same noise distribution (\(u \sim \mathcal{N}(0,.25)\)), the smaller variation in amplitudes further reduces the autocorrelation.

Visualization of all new simulated data:

Run simple GAM model to capture average trend:

## 
## Family: gaussian 
## Link function: identity 
## 
## Formula:
## y2 ~ s(x)
## 
## Parametric coefficients:
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0004277  0.0007666   0.558    0.577
## 
## Approximate significance of smooth terms:
##        edf Ref.df     F p-value    
## s(x) 8.993      9 94765  <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## R-sq.(adj) =  0.972   Deviance explained = 97.2%
## fREML = -17239  Scale est. = 0.014691  n = 25000

Below we have plotted 10 randomly selected modified sine waves (of the 250 in total), and the model fit for the sine waves.

Results: Autocorrelation in data Simulation II (b)

Selection of 10 random trials, and the residuals and fitted values of the GAM model:

Right panel

Autocorrelation of the model’s residuals (all 250 sine waves) for each lag (x-axis).