This package provides backend calculations for fitting functional mixed effects models. For the R package front-end, see the FunctionalMixedEffects.Rpkg repository.
Functional data, also known as curve data or waveform data, represent an extension to traditional data analysis where observations are entire functions rather than individual numbers. Of course, recording an infinite number of values in one curve is impossible, but accounting for the functional structure of the data is still worthwhile.
The book Functional Data Analysis by Ramsay and Silverman (2005) is a foundational reference in this space. Among all the techniques they develop for functional data analysis (FDA), this package will focus on splines, or rather B-splines. See the B-spline Wikipedia page for more detailed information on spline construction. A B-spline representable function with
where
The main reason to use splines for functional modeling is dimension-reduction. Instead of having to keep track of
Suppose
where
where
Mixed models are a tool used to control for non-independent errors in a regression. For example, clinical trials can often involve giving treatment to an individual multiple times (repeated measures problem). In that setting, each treatment response is not perfectly independent; observations may be correlated within an individual. The effect of an individual, often called a random effect, is usually not of interest, but is important to control for so that the underlying regression assumptions are met and the true treatment effect, often called a fixed effect can be accurately studied. Mixed models offer a framework for simultaneously accounting for random effects and estimating fixed effects.
In a Bayesian setting, mixed models are handled via the priors. Suppose that the
where
There is a lot more to be said about mixed models (See the Mixed Model Wikipedia page for loads of detail). This package is motivated primarily by a repeated measured perspective, and the template scripts found in the FunctionalMixedEffects.Rpkg
repo support this. However, the model fitting code itself is somewhat general (within the functional framework) and users are free to design their own suitable mixed model.
With background established, the purpose of this package is to fuse the two ideas of functional analysis and mixed models. The need is obvious: many exercise science and kinesiology research labs collect waveform data from subjects in the presence of various treatments and experimental conditions. Almost always several curves are taken from each participant, thus the desire to account for repeated measures.
The model structure implemented in this package can be summarized as follows: model each observed curve using the P-spline framework, then place a multivariate mixed model structure on the spline coefficients. In this way, each covariate, fixed and random, will have an interpretable functional effect on the outcome. The individual random effects will account for the fact that curves coming from a specific subject are more similar than those from another subject, and will appropriately adjust the certainty levels around the functional fixed effects of interest.
The model structure implemented in this pacakge can be written in several ways, with the most concise involving the matrix-normal distribution. While this is overkill for most applications, the matrix normal distribution effectively summarizes the model statement and the sampling scheme. Although looped model descriptions (i.e.
Suppose we observe
where
where
The mean structure for
Note that reusing
This model was designed, as many Bayesian hierarchical models are, to be full of conditional conjugacy. Thus, this package uses Gibbs sampling to draw from the model posterior and ultimately perform inference.
- Sampling the variance parameters
$\sigma^2$ ,$\tau^2$ , and$\lambda^2$ is straightforward: draw from an inverse-gamma conditional distribution where the rate depends on the total squared error. Similar relationships can be found in the conjugate prior wiki page. - Sampling the spline parameters
$\Theta$ can either be done individually or jointly. If done individually, the well known normal-normal regression conjugacy result can be used (see (Bayesian linear regression Wiki](https://en.wikipedia.org/wiki/Bayesian_linear_regression) page). - The same procedure can be used to sample
$U$ and$B$ , which is a matrix extension to the conjugate normal-normal result. However, this result does not appear to be online, so it is provided below in a general form. To sample$U$ , use the result on$\Theta - BX$ , and to sample$B$ , similarly use the result on$\Theta - UZ$ .
Suppose a
where
where
where