

---
title: "Bayesian SITAR model - An introduction"
author: "Satpal Sandhu"
date: '`r format(Sys.time(), "%B %d, %Y")`'
bibliography: [bibliography.bib]
csl: apa-7th-edition.csl
link-citations: yes
colorlinks: true
lang: en-US
zotero: true
output:
  rmarkdown::html_vignette:
    toc: yes
vignette: >
 %\VignetteIndexEntry{Bayesian SITAR model - An introduction}
  %\VignetteEngine{knitr::rmarkdown}
  \usepackage[utf8]{inputenc}
<!-- params: -->
<!--   EVAL: !r identical(Sys.getenv("NOT_CRAN"), "true") -->
---

```{r, SETTINGS-knitr, include=FALSE}
stopifnot(require(knitr))
options(width = 90)
opts_chunk$set(
  comment = NA,
  message = FALSE,
  warning = FALSE,
  # eval = if (isTRUE(exists("params"))) params$EVAL else FALSE,
  dev = "jpeg",
  dpi = 100,
  fig.asp = 0.8,
  fig.width = 5,
  out.width = "60%",
  fig.align = "center"
)
library(brms)
ggplot2::theme_set(theme_default())
```


```{=tex}
\newpage
\pagenumbering{arabic}
```
```{css, echo=FALSE}
p {
	text-indent: 0em;
}

p + p {
	text-indent: 2em;
}
```


\newpage

## Introduction
Human physical growth is not a smooth progression through time, but is inherently dynamic in nature. Growth proceeds in a series of spurts which reflect an increase in the growth velocity [@RN5278; @RN6913; @RN7906]. The adolescent growth spurt (also known as the pubertal growth spurt) is experienced by all individuals and is the most readily recognized aspect of adolescence. A clear knowledge of the growth dynamics during adolescence is essential when planning treatment to correct skeletal discrepancies such as scoliosis in which the spine has a sideways curve [@RN2761; @RN7982]. Similarly, the timing of the peak growth velocity spurt is an important factor to be considered when initiating growth modification procedures to correct skeletal malocclusion characterized by discrepancies in the jaw size [@RN7058; @RN6934; @RN7058a]

As the notion of change is central in studying growth, a correct view of the growth dynamics and the relationship between different growth phases can only be obtained from longitudinal growth data [@RN6071; @RN5278a]. Analysis of longitudinal growth data using an appropriate statistical method allows description of growth trajectories (distance and derivatives) and estimation of the timing and intensity of the adolescent growth spurt. Unlike in early years when linear growth curve model (GCMs) based on conventional polynomials were extensively used for studying human growth [@RN6217], the nonlinear nonlinear mixed effect are now gaining popularity in modelling longitudinal skeletal growth data such as height [@RN6217; @RN6071a].

## SITAR growth curve model - an overview
The super imposition by translation and rotation (*SITAR*) model [@Cole2010] is
a shape-invariant nonlinear mixed effect growth curve model that fits a
population average (i.e., mean average) curve to the data and aligns each
individual's growth trajectory to the population average curve by a set of three
random effects [@Cole2010]: the size relative to the mean growth curve (vertical
shift), the timing of the adolescent growth spurt relative to the mean age at
peak growth velocity (horizontal shift), and the intensity of the growth
velocity, i.e., the relative rate at which individuals grow during the
adolescent growth spurt in comparison to the mean growth intensity (horizontal
stretch). The concept of shape invariant model (SIM) was first described by
@Lindstrom1995 and later used by @Beath2007 for modelling infant
growth data (birth to 2 years). The current version of the *SITAR* model that we
describe below is developed by @Cole2010.

The *SITAR* is particularly useful in modelling human physical growth during adolescence. Recent studies have used *SITAR* for analyzing height and weight data [@nembidzaneUsingSITARMethod2020; @mansukoskiLifeCourseAssociations2019; @coleFiftyYearsChild2018; @riddellClassifyingGestationalWeight2017] and also to study jaw growth during adolescence [@Sandhu2020]. All these previous studies estimated *SITAR* model within the frequentist framework as implemented in the R package, 'sitar' package [@R-sitar].

## SITAR growth curve model - description
Consider a dataset comprised of $j$ individuals $(j = 1,..,j)$ where individual $j$ provides $n_j$ measurements ($i = 1,.., n_j$) of height ($y_{ij}$) recorded at age, $x_{ij}$.

```{=tex}
\begin{equation}
y_{ij}=\alpha_{0\ }+\alpha_{j\ }+\sum_{r=1}^{p-1}{\beta_r\mathbf{Spl}\left(\frac{x_{ij}-\bar{x_{ij}}-\left(\zeta_0+\zeta_j\right)}{e^{-\ \left(\left.\ \gamma_0+\ \gamma_j\right)\right.}}\right)}+e_{ij}
(\#eq:1)
\end{equation}
```
Where **Spl(.)** is the natural cubic spline function that generates the spline design matrix and $\beta_1,.,\beta_{p-1}$ are spline regression coefficient for the mean curve with $\alpha_0$, $\zeta_0$, $\gamma_0$ as the population average size, timing, and intensity parameters. By default, the predictor, age ($x_{ij}$) is mean centered by subtracting the mean age ($\bar{x}$) from it where $\bar{x} = \frac{1}{n} \sum_{i=1}^{n}x_{i.}$. The individual-specific random effects for size $(\alpha_j)$, timing $(\zeta_j)$ and intensity $(\gamma_j)$ describe how an individual's growth trajectory differs from the mean growth curve. The residuals $e_{ij}$ are also assumed to be normally distributed with zero mean and residual variance parameter $\sigma^2$ and are independent from the random effects. The random effects are assumed to be multivariate normally distributed with zero means and variance-covariance matrix $\Omega_2$. The $\Omega_2$ is unstructured (i.e., distinct variances and covariances between random effects) as follows:

```{=tex}
\begin{equation}
\begin{matrix}&\\&\\\left(\begin{matrix}\begin{matrix}\alpha_j\\\zeta_j\\\gamma_j\\\end{matrix}\\\end{matrix}\right)&\sim M V N\left(\left(\begin{matrix}\begin{matrix}0\\0\\0\\\end{matrix}\\\end{matrix}\right),\left(\begin{matrix}\sigma_{\alpha_j}^2&\rho_{\alpha_j\zeta_j}&\rho_{\alpha_j\gamma_j}\\\rho_{\zeta_j\alpha_j}&\sigma_{\zeta_j}^2&\rho_{\zeta_j\gamma_j}\\\rho_{\gamma_j\alpha_j}&\rho_{\gamma_j\zeta_j}&\sigma_{\gamma_j}^2\\\end{matrix}\right)\right)\mathrm{,\ for\ individual\ j\ =\ 1,} \ldots\mathrm{,J} \\\end{matrix}
(\#eq:2)
\end{equation}
```
<br/>

## Model estimation - frequentist vs. Bayesian
There are two competing philosophies of model estimation [@bland1998; @Schoot2014]: the Bayesian (based on Bayes' theorem) and the frequentist (e.g., maximum likelihood estimation) approaches. While the frequentist approach was predominant in the earlier years, the advent of powerful computers has given a new impetus to the Bayesian analysis [@bland1998; @Schoot2014; @hamra2013]. As a result, Bayesian statistical methods are becoming ever more popular in applied and fundamental research. The key difference between Bayesian statistical inference and frequentest statistical methods concerns the nature of the unknown parameters. In the frequentist framework, a parameter of interest is assumed to be unknown, but fixed. That is, it is assumed that in the population there is only one true population parameter, for example, one true mean or one true regression coefficient. In the Bayesian view of subjective probability, all unknown parameters are treated as uncertain and therefore should be described by a probability distribution [@Schoot2014]. A particular attractive feature of Bayesian modelling is its ability to handle otherwise complex model specifications such as hierarchical model (i.e,., multilevel/mixed-effects models) that involve nested data structures (e.g., repeated height measurements in individuals) [@hamra2013]. Bayesian statistical methods are becoming popular in applied and clinical research [@Schoot2014]. 

There are three essential components underlying Bayesian statistics ([@bayes1763lii; @stigler1986laplace]): the *prior distribution,* the *likelihood function,* and the *posterior distribution*. The *prior distribution* refers to all knowledge available *before* seeing the data whereas the *likelihood function* expresses the information in the data given the parameters defined in the model. The third component (i.e., *posterior distribution*) is based on combining the first two components via Bayes' theorem and the results are summarized by the so-called *posterior inference*. The *posterior distribution*, therefore, reflects one's updated knowledge, balancing prior knowledge with observed data.

The task of combining these components together can yield a complex model in which the exact distribution of one or more variables is unknown and estimators that rely on assumptions of normality may perform poorly. This limitation is often mitigated by estimating the Bayesian models using Markov Chain Monte Carlo (MCMC). Unlike deterministic maximum-likelihood algorithms, MCMC is a stochastic procedure that repeatedly generates random samples that characterize the distribution of parameters of interest [@hamra2013]. The popular software platform for Bayesian estimation is the BUGS family including 
WinBUGS [@lunn2000], OpenBUGS [@spiegelhalter2007openbugs], JAGS [@Plummer2003JAGSAP]. More recently, the software Stan has been developed to achieve higher computational and algorithmic efficiency by using the No-U-Turn Sampler (NUTS), which is an adaptive variant of Hamiltonian Monte Carlo (HMC) [@Hoffman2011; @neal2011; @gelman2015].

## Bayesian SITAR model

<!-- https://github.com/ASKurz/Statistical_Rethinking_with_brms_ggplot2_and_the_tidyverse_2_ed/blob/master/14.Rmd -->

<!-- ### Conventional multilevel growth model. -->

### Two-level SITAR model
#### Univariate model
Below we describe Bayesian model specification for a two-level *SITAR* model
([see also overview section][SITAR growth curve model - an overview])
and the default priors.

##### Model specification
To get a better understanding of the data generative mechanism and for the ease of showing prior specification for each individual parameter, we re express the above model \@ref(eq:1) as as follows:

<!-- color{#A65141} -->


\begin{equation}
\begin{aligned}
\text{y}_{ij} & \sim \operatorname{Normal}(\mu_{ij}, \sigma) \\
\\
\mu_{ij} & = \alpha_0+ \alpha_j+\sum_{r=1}^{p-1}{\beta_r\mathbf{Spl}\left(\frac{x_{ij}-\bar{x_{ij}}-\left(\zeta_0+\zeta_j\right)}{e^{-\ \left(\left.\ \gamma_0+\gamma_j\right)\right.}}\right)} \\
\sigma & = \sigma_\epsilon \\
\\
\begin{bmatrix} \alpha_{j} \\ \zeta_{j} \\ \gamma_{j} \end{bmatrix} & \sim {\operatorname{MVNormal}\begin{pmatrix} \begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix},\ \mathbf S \mathbf R \mathbf S \end{pmatrix}} \\
\\
\mathbf S & = \begin{bmatrix} \sigma_{\alpha_j} & 0 & 0 \\ 0 &\sigma_{\zeta_j} & 0 \\ 0 &  0 & \sigma_{\gamma_j} \end{bmatrix} \\
\\
\mathbf R & = \begin{bmatrix} 1  & \rho_{\alpha_j\zeta_j} & \rho_{\alpha_j\gamma_j} \\\rho_{\zeta_j\alpha_j} & 1 & \rho_{\zeta_j\gamma_j} \\\rho_{\gamma_j\alpha_j} & \rho_{\gamma_j\zeta_j} & 1 \end{bmatrix} \\
\\
\alpha_0   & \sim \operatorname{student\_t}(3,\ y_{mean},\  {y_{sd}},\ autoscale= TRUE) \\
\zeta_0   & \sim \operatorname{student\_t}(3,\ 0,\ 3.5, \ autoscale= FALSE) \\
\gamma_0  & \sim \operatorname{student\_t}(3,\ 0,\ 1.5, \ autoscale= FALSE) \\
\beta_1 \text{,..,} \beta_r & \sim \operatorname{student\_t}(3,\ 0, \ \mathbf {X_{scaled}},\ autoscale= TRUE) \\
\alpha_j   & \sim \operatorname{student\_t_{Half}}(3,\ {0},\  {y_{sd}}, \ autoscale= TRUE) \\
\zeta_j   & \sim \operatorname{student\_t_{Half}}(3,\ {0},\  {2}, \ autoscale= FALSE) \\
\gamma_j   & \sim \operatorname{student\_t_{Half}}(3,\ {0},\  {0.5}, \ autoscale= FALSE) \\
\sigma_\epsilon & \sim \operatorname{exponential}(y_{sd}, \ autoscale= TRUE) \\
\mathbf R & \sim \operatorname{LKJ}(1),
\end{aligned}
(\#eq:4)
\end{equation}


The first line in the above equation is the likelihood which states that outcome
is distributed with mean *mu* and standard deviation, *sigma*. The *mu* is the
function of growth curve parameters as described earlier \@ref(eq:1). The
residuals are assumed to be independent and normally distributed with 0 mean and
a $n_j \times n_j$ dimensional identity covariance matrix with a diagonal
constant variance parameter, $\sigma_\epsilon$ i.e, $I\sigma_\epsilon$ where $I$
is the identity matrix (diagonal matrix of 1s), and $\sigma_\epsilon$ is the
residual standard deviation. The assumption of homoscedasticity of residuals
(constant level 1 variance) can be relaxed.

##### Priors
We follow the recommendations made in the popular packages
[rstanrm](https://rdrr.io/cran/rstanarm/man/priors.html) and
[brms](https://rdrr.io/cran/brms/man/set_prior.html) for prior specification.
Technically, the prior used in 'rstanrm' and 'brms' packages are data-dependent
and, hence 'weakly informative'. This is because priors are scaled based on the
distribution (i.e., standard deviation) of the outcome and the predictor(s).
However, the amount of information used is weak and mainly regulatory in nature
that helps in stabilizing the computation. An important feature of such priors is that defaults priors are reasonable for many models.

The 'bsitar' package allows setting prior for each parameter individually. For
example, to set prior for the population average regression coefficient and the
standard deviation of the group level random effects for size parameter  `a`,
the arguments used are `a_prior_beta` and `a_prior_sd.` Like 'brms' and
'rstanrm', the 'bsitar' package offers a full flexibility in setting a wide
range of priors that encourage the users to specify priors that actually reflect
their prior knowledge about the human growth processes. We follow a carefully
crafted approach that is based on the recommendations made in the
[brms](https://rdrr.io/cran/brms/man/set_prior.html) and
[rstanrm](https://rdrr.io/cran/rstanarm/man/priors.html) packages. For example,
while we follow the 'brms' package in using the 'student_t' distribution for the
regression coefficients as well as the standard deviation for group level random
effects (with default 3 degree of freedom), we set 'exponential' distribution
for the residual standard deviation parameter as suggested in the 'rstanarm'
package. Note that 'rstanrm' recommends `normal` distribution for population and
random effect intercepts whereas the 'brms' uses the 'student_t' distribution
for these parameters.

Similar to the 'brms' and 'rstanarm' packages, the 'bsitar' package
allows user to control the the scale parameter for the location-scale based
distributions such as 'normal' and 'student_t' via an auto scaling option. Here
again we adopt an amalgamation of the strategies offered by the 'brms' and
'rstanarm' packages. While 'rstanarm' earlier used to set autoscale as `TRUE`
which scaled distribution by multiplying it with a fixed value $2.5$ (recently
authors changed this behavior to FALSE), the 'brms' package sets scale factor as
$1.0$ or $2.5$ depending on the the Median Absolute Deviation (MAD) of the
outcome. If MAD is less than $2.5$, it scales prior by a factor of $2.5$
otherwise the scale factor is $1.0$ (i.e., no auto scaling). The 'bsitar'
package, on the other hand, offers full flexibility in choosing the scale factor
via a built in option `autoscale`. For example, scaling factor can be set as any
real number such as $1.5$ (e.g., autoscale = 1.5) or setting the  `autoscale` as
`TRUE` (autoscale = TRUE) which sets in default scaling factor as  $2.5$.  The
`autoscale` option is available for all location-scale based distibutions such
as `normal`, `student_t`, `cauchy` etc. We strongly recommend to go through the
documentation on priors included in the
[brms](https://rdrr.io/cran/brms/man/set_prior.html) and
[rstanrm](https://rdrr.io/cran/rstanarm/man/priors.html) packages.


Below we briefly describe the default approach used in setting the 'weakly
informative' priors for the regression coefficients as well as the standard
deviation of random effects for `a` (size), `b` (timing) and `c` (intensity)
parameters and their correlations.

* The population regression parameter `a` (size) is assigned 'student_t' prior centered at $y_{mean}$ (i.e., mean of the outcome) with scale defined as the standard deviation of the outcome $y_{sd}$ multiplied by the default scaling factor $2.5$ i.e., `student_t(3, ymean, ysd, autoscale = TRUE)`. The prior on the standard  deviation of the random effect parameter `a` is identical to the
'student_t'  with mean `0` and scale identical to the regression parameter with
the exception that it is centered at mean `0` i.e, `i.e., `student_t(3, 0, ysd,
autoscale = TRUE)`.

* For population regression parameter `b` (timing), the default prior is 'student_t' with mean `0` and scale $3.5$ i.e, `'student_t'(3, 0, 3.5, autoscale = FALSE)`. Note that unlike parameter `a`, autoscale option is set as `FALSE`. Since predictor `age` is typically mean centered when fitting the *SITAR* model, the prior implies that 95% mass of the distribution (assuming distribution approaches normal curve) would cover between 6 and 20 years when mean age is `13` years. Depending on the mean age and whether data are for males or females, the scale factor can be adjusted
accordingly. Prior for the sd parameter is 'student_t' but with mean `0` and sd
2.0 (`student_t(3, 0, 2.0, autoscale = FALSE)`) implying that 95% mass of the
distribution will cover $\pm 4.0$ years for the individual variation in the
timing parameter `b`.

* The default prior for the population average intensity regression parameter `c` is
'student_t' with mean `0` and scale `1.5` i.e, `student_t(3, 0, 1.5, autoscale =
FALSE)`. Since intensity parameter is estimated on  `exp` scale, the above prior
implies that 95% mass of the distribution would cover intensity between
`exp(-3)` and `exp(3)` i.e., `0.05` and `20.0` unit/year. Prior for the sd
parameter (i.e., the random effect parameter `c`) is again 'student_t' with mean
`0` and sd `1.25` (`student_t(3, 0, 1.25, autoscale = FALSE)`) indicating that
95% mass of the distribution for individual variation in the timing will cover
$\pm exp(1.25)$ i.e, `0.28` and `3.50` unit/year.

* The prior for the correlations between random effect parameters follow
Lewandowski-Kurowicka-Joe (LKJ) distribution. The 'LKJ' prior is specified via a
single parameter 'eta'. If `eta = 1` (the default) all correlations matrices are
equally likely `a priori`. If `eta > 1`, extreme correlations become less
likely, whereas `0 < eta < 1` results in higher probabilities for extreme
correlations. See [brms](https://rdrr.io/cran/brms/man/set_prior.html) for more
details.

#### Multivariate model specification

A two level Bayesian *SITAR* model described [earlier][Univariate model] can be
easily extended to analyze two or more outcome simultaneously. Consider two outcomes (NA and PA) measured repeatedly on $j$ individuals $(j = 1,..,j)$ where individual $j$ provides $n_j$ measurements ($i = 1,.., n_j$) of $y_{ij}^\text{NA}$ (outcome NA) and $y_{ij}^\text{PA}$ (outcome NA) recorded at age, $x_{ij}$. A 
multivariate model is then written as follows \@ref(eq:5):


\begin{equation}
\begin{aligned}
\begin{bmatrix} \text{NA}_{ij} \\ \text{PA}_{ij} \end{bmatrix} & \sim \operatorname{MVNormal}\begin{pmatrix} \begin{bmatrix} 
\mu_{ij}^\text{NA} \\ \mu_{ij}^\text{PA} \end{bmatrix}, \mathbf {\Sigma_{Residual}} \end{pmatrix} \\
\\
\mu_{ij}^{\text{NA}} & = \alpha_0^\text{NA}+ \alpha_j^\text{NA}+\sum_{r^\text{NA}=1}^{p^\text{NA}-1}{\beta_r^\text{NA}\mathbf{Spl}^\text{NA}\left(\frac{x_{ij}-\bar{x_{ij}}-\left(\zeta_0^\text{NA}+\zeta_j^\text{NA}\right)}{e^{-\ \left(\left.\ \gamma_0^\text{NA}+\gamma_j^\text{NA}\right)\right.}}\right)} \\
\\
\mu_{ij}^{\text{PA}} & = \alpha_0^\text{PA}+ \alpha_j^\text{PA}+\sum_{r^\text{PA}=1}^{p^\text{PA}-1}{\beta_r^\text{PA}\mathbf{Spl}^\text{PA}\left(\frac{x_{ij}-\bar{x_{ij}}-\left(\zeta_0^\text{PA}+\zeta_j^\text{PA}\right)}{e^{-\ \left(\left.\ \gamma_0^\text{PA}+\gamma_j^\text{PA}\right)\right.}}\right)} \\
\\
\mathbf {\Sigma_{Residual}} & = \mathbf S_W \mathbf R_W \mathbf S_W \\
\\
\mathbf S_W & = \begin{bmatrix}
\sigma_{ij}^\text{NA} & 0 \\ 
0 & \sigma_{ij}^\text{PA} \\
\end{bmatrix} \\
\\
\mathbf R_W & = \begin{bmatrix}
1 & \rho_{\sigma_{ij}^\text{NA}\sigma_{ij}^\text{PA}} \\
\rho_{\sigma_{Ij}^\text{PA}\sigma_{Ij}^\text{NA}}  & 1 
\end{bmatrix} \\
\\
\begin{bmatrix} \alpha_{j}^\text{NA} \\ \zeta_{j}^\text{NA} \\ \gamma_{j}^\text{NA} \\ \alpha_{j}^\text{PA} \\ \zeta_{j}^\text{PA} \\ \gamma_{j}^\text{PA} \end{bmatrix} & \sim {\operatorname{MVNormal}\begin{pmatrix} \begin{bmatrix} 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \end{bmatrix},\ \mathbf {\Sigma_{ID}} \end{pmatrix}} \\
\\
\\
\mathbf {\Sigma_{ID}} & = \mathbf S_{ID} \mathbf R_{ID} \mathbf S_{ID} \\
\\
\mathbf S_{ID} & = \begin{bmatrix} 
\alpha_{j}^\text{NA} & 0 & 0 & 0 & 0 & 0 \\ 
0 & \zeta_{j}^\text{NA} &  0 & 0 & 0 & 0 \\ 
0 & 0 & \gamma_{j}^\text{NA} & 0 & 0 & 0 \\ 
0 & 0 & 0 & \alpha_{j}^\text{PA} & 0 & 0 \\ 
0 & 0 & 0 & 0 & \zeta_{j}^\text{PA}  & 0 \\ 
0 & 0 & 0 & 0 & 0 & \gamma_{j}^\text{PA} \\ 
\end{bmatrix} \\
\\
\mathbf R_{ID} & = \begin{bmatrix}
1 & \rho_{\alpha_{j}^\text{NA}\zeta_{j}^\text{NA}} & \rho_{\alpha_{j}^\text{NA}\gamma_{j}^\text{NA}} & \rho_{\alpha_{j}^\text{NA}\alpha_{j}^\text{PA}} & \rho_{\alpha_{j}^\text{NA}\zeta_{j}^\text{PA}} & \rho_{\alpha_{j}^\text{NA}\gamma_{j}^\text{PA}} \\
\rho_{\zeta_{j}^\text{NA}\alpha_{j}^\text{NA}} & 1 & \rho_{\zeta_{j}^\text{NA}\gamma_{j}^\text{NA}}  & \rho_{\zeta_{j}^\text{NA}\alpha_{j}^\text{PA}} & \rho_{\zeta_{j}^\text{NA}\zeta_{j}^\text{PA}} & \rho_{\zeta_{j}^\text{NA}\gamma_{j}^\text{PA}} \\
\rho_{\gamma_{j}^\text{NA}\alpha_{j}^\text{NA}} & \rho_{\gamma_{j}^\text{NA}\zeta_{j}^\text{NA}}  & 1 & \rho_{\gamma_{j}^\text{NA}\alpha_{j}^\text{PA}} & \rho_{\gamma_{j}^\text{NA}\zeta_{j}^\text{PA}} & \rho_{\gamma_{j}^\text{NA}\gamma_{j}^\text{PA}} \\
\rho_{\alpha_{j}^\text{NA}\alpha_{j}^\text{PA}} & \rho_{\zeta_{j}^\text{NA}\alpha_{j}^\text{PA}} & \rho_{\gamma_{j}^\text{NA}\alpha_{j}^\text{PA}} & 1 & \rho_{\alpha_{j}^\text{PA}\zeta_{j}^\text{PA}} & \rho_{\alpha_{j}^\text{PA}\gamma_{j}^\text{PA}} \\
\rho_{\alpha_{j}^\text{NA}\zeta_{j}^\text{PA}} & \rho_{\zeta_{j}^\text{NA}\zeta_{j}^\text{PA}} & \rho_{\gamma_{j}^\text{NA}\zeta_{j}^\text{PA}} & \rho_{\zeta_{j}^\text{PA}\alpha_{j}^\text{PA}} & 1 & \rho_{\zeta_{j}^\text{PA}\gamma_{j}^\text{PA}} \\
\rho_{\alpha_{j}^\text{NA}\gamma_{j}^\text{PA}} & \rho_{\zeta_{j}^\text{NA}\gamma_{j}^\text{PA}} & \rho_{\gamma_{j}^\text{NA}\gamma_{j}^\text{PA}} & \rho_{\gamma_{j}^\text{PA}\alpha_{j}^\text{PA}} & \rho_{\gamma_{j}^\text{PA}\zeta_{j}^\text{PA}}  & 1 
\end{bmatrix} \\
\\
\alpha_0^\text{NA}   & \sim \operatorname{student\_t}(3,\ y^\text{NA}_{mean},\  {y^\text{NA}_{sd}},\ autoscale= TRUE) \\
\alpha_0^\text{PA}   & \sim \operatorname{student\_t}(3,\ y^\text{PA}_{mean},\  {y^\text{PA}_{sd}},\ autoscale= TRUE) \\
\zeta_0^\text{NA} & \sim \operatorname{student\_t}(3,\ 0, 3.5,\ autoscale= FALSE) \\
\zeta_0^\text{PA} & \sim \operatorname{student\_t}(3,\ 0, 3.5,\ autoscale= FALSE) \\
\gamma_0^\text{NA} & \sim \operatorname{student\_t}(3,\ 0, 1.5,\ autoscale= FALSE) \\
\gamma_0^\text{PA} & \sim \operatorname{student\_t}(3,\ 0, 1.5,\ autoscale= FALSE) \\
\beta_1^\text{NA} \text{,..,} \beta_r^\text{NA} & \sim \operatorname{student\_t}(3,\ 0, \ \mathbf {X^\text{NA}_{scaled}},\ autoscale= TRUE) \\
\beta_1^\text{PA} \text{,..,} \beta_r^\text{PA} & \sim \operatorname{student\_t}(3,\ 0, \ \mathbf {X^\text{PA}_{scaled}},\ autoscale= TRUE) \\
\alpha_j^\text{NA}   & \sim \operatorname{student\_t_{Half}}(3,\ {0},\  {y^\text{NA}_{sd}},\ autoscale= TRUE) \\
\alpha_j^\text{PA}   & \sim \operatorname{student\_t_{Half}}(3,\ {0},\  {y^\text{PA}_{sd}},\ autoscale= TRUE) \\
\zeta_j^\text{NA}  & \sim \operatorname{student\_t_{Half}}(3,\ {0},\ {2},\ autoscale= FALSE) \\
\zeta_j^\text{PA} & \sim \operatorname{student\_t_{Half}}(3,\ {0},\ {2},\ autoscale= FALSE) \\
\gamma_j^\text{NA} & \sim \operatorname{student\_t_{Half}}(3,\ {0},\ {0.5},\ autoscale= FALSE) \\
\gamma_j^\text{PA} & \sim \operatorname{student\_t_{Half}}(3,\ {0},\ {0.5},\ autoscale= FALSE) \\
\sigma_{ij}^\text{NA} & \sim \operatorname{exponential}({y^\text{NA}_{sd}}, \ autoscale = TRUE) \\
\sigma_{ij}^\text{PA} & \sim \operatorname{exponential}({y^\text{PA}_{sd}}, \ autoscale = TRUE) \\
\mathbf R_W & \sim \operatorname{LKJ}(1) \\
\mathbf R_{ID} & \sim \operatorname{LKJ}(1),
\end{aligned}
(\#eq:5)
\end{equation}



where $\text{NA}$ and $\text{PA}$ superscripts indicate which variable is
connected with which parameter. This is a straight multivariate generalization
from the previous model, \@ref(eq:4). At individual level, we have six
parameters varying across individuals, resulting in an $6 \times 6$ $\mathbf
S_{ID}$ matrix and an $6 \times 6$ $\mathbf R_{ID}$ matrix. The within
individual variability is captured by the residual parameters which include $2
\times 2$ $\mathbf S_{W}$ matrix and an $2 \times 2$ $\mathbf R_{W}$ matrix. The
priors described above for the [Univariate model specification]) are applied to
each outcome. The prior on residual correlation between outcomes is 'lkj' prior
as described earlier (see [Univariate model specification]).



#### References
