Mixed effects converters#

The following classes can be used for converting irregular functional data to basis representation using the mixed effects model.

skfda.representation.conversion.MinimizeMixedEffectsConverter(basis)

Mixed effects to-basis-converter using scipy.optimize.minimize.

skfda.representation.conversion.EMMixedEffectsConverter(basis)

Mixed effects to-basis-converter using the EM algorithm.

Mixed effects converters#

This module contains the classes for converting irregular data to basis representation using the mixed effects model.

The use of the mixed effects model for conversion of irregularly sampled functional data to a basis representation is detailed in James[1]. In the following, we provide a brief overview of the model for 1-dimensional functional data.

The mixed effects model for functional data#

Let \(\{x_i(t)\}_{i=1}^N\) be a functional dataset where each \(x_i\) is a function from \([a, b]\) to \(\mathbb{R}\) and we have the measurements of \(x_i(t)\) at \(M_i\) points of the domain \(\mathbf{t}_i = (t_{i1}, t_{i2}, \dots, t_{iM_i})\). That is, we have the irregularly sampled data: \(\{x_i(\mathbf{t}_i))\}_{i=1}^N\), where \(x_i(\mathbf{t}_i) = (x_i(t_{i1}), x_i(t_{i2}), \dots, x_i(t_{iM_i}))\). Let \(\{\phi_b\}_{b=1}^B\) be the basis that we want to express the data in. We denote by \(\pmb{\phi}(t)\) the vector of evaluations \((\phi_1(t), \phi_2(t), \dots, \phi_B(t))\).

The mixed effects model assumes the data comes from the model (for each \(1\leq i \leq N\) and \(a\leq t \leq b\)):

\[x_i(t) = \pmb{\phi}(t)^T (\pmb{\beta} + \pmb{\gamma}_i) + \epsilon_i(t),\]

where \(\pmb{\beta}\in\mathbb{R}^B\) is an unknown constant vector called the fixed effects (we will call it the mean); \(\{\pmb{\gamma}_i\}_{i=1}^N\subseteq\mathbb{R}^B\) are unknown random vectors called the random effects and they are assumed to be independent and identically with a normal distribution of mean 0 and covariance matrix \(\pmb{\Gamma}\) (which we call covariance for short); and \(\epsilon_i(t)\) is a random noise term that is assumed to have a normal distribution with mean 0 and variance \(\sigma^2\) (which we call sigmasq). We assume that \(\{\epsilon_i(t)\}_{i,t}\cup\{\pmb{\gamma}_i\}_i\) are independent.

In order to work with this model and the data available, we denote (for each \(1 \leq i \leq N\)):

\[\begin{split}\pmb{x}_i = \left(\begin{array}{c} x_i(t_{i1}) \\ x_i(t_{i2}) \\ \vdots \\ x_i(t_{iM_i}) \end{array}\right), \qquad \pmb{\Phi}_i = \left(\begin{array}{c} \pmb{\phi}(t_{i1})^T \\ \pmb{\phi}(t_{i2})^T \\ \vdots \\ \pmb{\phi}(t_{iM_i})^T \end{array}\right), \qquad \pmb{\epsilon}_i = \left(\begin{array}{c} \epsilon_i(t_{i1}) \\ \epsilon_i(t_{i2}) \\ \vdots \\ \epsilon_i(t_{iM_i}) \end{array}\right),\end{split}\]

and we have that our model can be written as (for each \(1 \leq i \leq N\)):

\[\pmb{x}_i = \pmb{\Phi}_i (\pmb{\beta} + \pmb{\gamma}_i) + \pmb{\epsilon}_i.\]

We call \(\pmb{x}_i\) the i-th values vector, and \(\pmb{\Phi}_i\) the i-th basis evaluations matrix.

Fitting the model#

The model is fitted by maximizing its likelihood to get the MLE (Maximum Likelihood Estimates) of \(\pmb{\beta}\), \(\pmb{\Gamma}\) and \(\sigma\), and then computing the random effects (\(\{\pmb{\gamma}_i\}_i\)) with their least squares linear estimators.

The MLE are computed using either the EM algorithm (EMMixedEffectsConverter, Nan Laird and Stram[2]), or by minimizing the profile loglikelihood of the model with generic numerical optimization (MinimizeMixedEffectsConverter, Lindstrom and Bates[3]).

The examples Mixed effects model for irregular data and Mixed effects model for irregular data: robustness of the conversion illustrate the basic usage of these converters.

References