Get these notes as PDF here.
In neuroscience, we often want to understand how neuronal spiking relates to other variables. For this, tools like linear regression and correlation often work well enough. However, linear approaches presume that the underlying relationships are linear and the noise is Gaussian, neither of which are true for neural datasets. The Generalized Linear Model (GLM) extends linear methods to better account for nonlinearity and non-Gaussian noise.
GLMs for spike train analysis
We're interested in understanding how a neural spike train
Two types of GLM that are common in spike train analysis:
- The Poisson GLM assumes that spikes arise from an inhomogeneous Poisson process with time-varying rate
that depends log-linearly on the covariates . In practice, it is common to treat the Poisson GLM in discrete time by assuming that the rate is constant within each time-bin:
- The Bernoulli GLM models each time-bin of a binary, discrete-time spike train
as a Bernoulli "coin flip" with .
Maximum likelihood
GLMs are typically estimated using maximum likelihood when testing how covariates
In practice, likelihood maximization is typically phrased in terms of minimizing the negative log-likelihood. Working with log-likelihood is more numerically stable, and the problem is phrased as minimization so that it is more straightforward to plug-in to off-the-shelf minimization code.
Assuming observations are independent, the negative log-likelihood factors into a sum over time-points. Equivalently, one can minimize the average negative log-likelihood, over samples,
Gradient and Hessian for the Poisson GLM
We can calculate the gradient and Hessian for the Poisson GLM by substituting the Poisson probability density function,
Because the term
Finding weight
In matrix notation, these derivatives can then be written as:
Gradient and Hessian for the Bernoulli GLM
The Bernoulli GLM is similar, with the observation probability given by the Bernoulli distribution
Then, using
The gradient and Hessian of of
In matrix notation:
Iteratively reweighted least squares
PPGLMs can also be fit to spike train data using Iteratively Reweighted Least Squares (IRLS) . Recall that for a linear model
The IRLS approach phrases optimizing the parameters of the GLM in terms of repeated iterations of a reweighted least-squares problem. To derive this, first recall the definition of the Newton-Raphson update:
For the Poisson GLM, this is
For e.g. the Poisson GLM, IRLS rewrites this as a least squares problem by defining weights
Expected log-likelihoods
It's also possible to approximately fit
The term
The Hessian also has a closed form. This avoids having to recompute the re-weighted mean/covariances on every iteration. However, one still must calculate a mean and covariance initially. This approximation will only remain valid in the case that
Edit: it seems like the Poisson GLM for Gaussian