Here we describe the details of the Satterthwaite degrees of freedom calculations.
Satterthwaite degrees of freedom for asymptotic covariance
In Christensen (2018) the Satterthwaite
degrees of freedom approximation based on normal models is well detailed
and the computational approach for models fitted with the
lme4
package is explained. We follow the algorithm and
explain the implementation in this mmrm
package. The model
definition is the same as in Details of the
model fitting in mmrm
.
We are also using the same notation as in the Details of the Kenward-Roger calculations. In particular, we assume we have a contrast matrix with which we want to test the linear hypothesis . Further, is the inverse of the Hessian matrix of the log-likelihood function of evaluated at the estimate , i.e. the observed Fisher Information matrix as a consistent estimator of the variance-covariance matrix of . is the asymptotic covariance matrix of .
One-dimensional contrast
We start with the case of a one-dimensional contrast, i.e. . The Satterthwaite adjusted degrees of freedom for the corresponding t-test are then defined as: where is the scalar in the numerator and we can identify it as the variance estimate for the estimated scalar contrast . The computational challenge is essentially to evaluate the denominator in the expression for , which amounts to computing the -dimensional gradient of (for the given contrast matrix ) at the estimate . We already have the variance-covariance matrix of the variance parameter vector from the model fitting.
Jacobian approach
However, if we proceeded in a naive way here, we would need to
recompute the denominator again for every chosen
.
This would be slow, e.g. when changing
every time we want to test a single coefficient within
.
It is better to instead evaluate the gradient of the matrix valued
function
,
which is therefore the Jacobian, with regards to
,
.
Imagine
as the the 3-dimensional array with
faces of size
.
Left and right multiplying each face by
and
respectively leads to the
-dimensional
gradient
.
Therefore for each new contrast
we just need to perform simple matrix multiplications, which is fast
(see h_gradient()
where this is implemented). Thus, having
computed the estimated Jacobian
,
it is only a matter of putting the different quantities together to
compute the estimate of the denominator degrees of freedom,
.
Jacobian calculation
Currently, we evaluate the gradient of
through function h_jac_list()
. It uses automatic
differentiation provided in TMB
.
We first obtain the Jacobian of the inverse of the covariance matrix of coefficient (), following the Kenward-Roger calculations. Please note that we only need matrices.
Then, to obtain the Jacobian of the covariance matrix of coefficient, following the algorithm, we use estimated in the fit to obtain the Jacobian.
The result is a list (of length where is the dimension of the variance parameter ) of matrices of , where is the dimension of .
Multi-dimensional contrast
When we are testing multiple contrasts at once. Here an F-statistic is calculated, and we are interested in estimating an appropriate denominator degrees of freedom for , while assuming are the numerator degrees of freedom. Note that only in special cases, such as orthogonal or balanced designs, the F distribution will be exact under the null hypothesis. In general, it is an approximation.
The calculations are described in detail in Christensen (2018), and we don’t repeat them
here in detail. The implementation is in h_df_md_sat()
and
starts with an eigen-decomposition of the asymptotic variance-covariance
matrix of the contrast estimate,
i.e. .
The F-statistic can be rewritten as a sum of
statistics based on these eigen-values. The corresponding random
variables are independent (by design because they are derived from the
orthogonal eigen-vectors) and essentially have one degree of freedom
each. Hence, each of the
statistics is treated as above in the one-dimensional contrast case,
i.e. the denominator degree of freedom is calculated for each of them.
Finally, using properties of the F distribution’s expectation, the
denominator degree of freedom for the whole F statistic is derived.
Satterthwaite degrees of freedom for empirical covariance
In Bell and McCaffrey (2002) the Satterthwaite degrees of freedom in combination with a sandwich covariance matrix estimator are described.
One-dimensional contrast
For one-dimensional contrast, following the same notation in Details of the model fitting in
mmrm
and Details of the
Kenward-Roger calculations, we have the following derivation. For an
estimator of variance with the following term
where takes the value of , or , and takes , , or respectively, is a column vector, then can be decomposed into the a weighted sum of independent distribution, where the weights are the eigenvalues of the matrix with elements
where
corresponds to the rows of subject .
So the degrees of freedom can be represented as
where are the eigenvalues of . Bell and McCaffrey (2002) also suggests that can be chosen as identify matrix, so .
Following Weighted Least Square Estimator, we can transform the original into to use the above equations.
To avoid repeated computation of matrix , etc for different contrasts, we calculate and cache the following
which is a matrix. With different contrasts, we need only calculate the following to obtain a matrix, can be computed with .
To obtain the degrees of freedom, and to avoid eigen computation on a large matrix, we can use the following equation
The scale parameter is not used throughout the package.
The proof is as following
- Proof of
Let has dimension , has dimension
so
- Proof of and if
Following eigen decomposition, we have where is diagonal matrix, is orthogonal matrix.
Using the previous formula that , we have
and can be further expressed as