Here we describe the details of the Satterthwaite degrees of freedom calculations.
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 C∈Rc×p with which we want to test the linear hypothesis Cβ=0. Further, W(ˆθ) 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 ˆθ. Φ(θ)={X⊤Ω(θ)−1X}−1 is the asymptotic covariance matrix of ˆβ.
We start with the case of a one-dimensional contrast, i.e. c=1. The Satterthwaite adjusted degrees of freedom for the corresponding t-test are then defined as: ˆν(ˆθ)=2f(ˆθ)2f′(ˆθ)⊤W(ˆθ)f′(ˆθ) where f(ˆθ)=CΦ(ˆθ)C⊤ is the scalar in the numerator and we can identify it as the variance estimate for the estimated scalar contrast Cˆβ. The computational challenge is essentially to evaluate the denominator in the expression for ˆν(ˆθ), which amounts to computing the k-dimensional gradient f′(ˆθ) of f(θ) (for the given contrast matrix C) at the estimate ˆθ. We already have the variance-covariance matrix W(ˆθ) of the variance parameter vector θ from the model fitting.
However, if we proceeded in a naive way here, we would need to
recompute the denominator again for every chosen C. This would be slow, e.g. when changing
C 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 θ, J(θ)=∇θΦ(θ). Imagine J(θ) as the the
3-dimensional array with k faces of
size p×p. Left and right
multiplying each face by C and
C⊤ respectively leads to the
k-dimensional gradient f′(θ)=CJ(θ)C⊤. Therefore for each new contrast C we just need to perform simple matrix
multiplications, which is fast (see h_gradient()
where this
is implemented). Thus, having computed the estimated Jacobian J(ˆθ), it is only a
matter of putting the different quantities together to compute the
estimate of the denominator degrees of freedom, ˆν(ˆθ).
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 (Φ(θ)−1), following the Kenward-Roger calculations. Please note that we only need Ph 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 k where k is the dimension of the variance parameter θ) of matrices of p×p, where p is the dimension of β.
When c>1 we are testing multiple contrasts at once. Here an F-statistic F=1c(Cˆβ)⊤(CΦ(ˆθ)C⊤)−1C⊤(Cˆβ) is calculated, and we are interested in estimating an appropriate denominator degrees of freedom for F, while assuming c 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. CΦ(ˆθ)C⊤. The F-statistic can be rewritten as a
sum of t2 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
t 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.
In Bell and McCaffrey (2002) the Satterthwaite degrees of freedom in combination with a sandwich covariance matrix estimator are described.
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
v=sc⊤(X⊤X)−1∑iX⊤iAiϵiϵ⊤iAiXi(X⊤X)−1c
where s takes the value of nn−1, 1 or n−1n, and Ai takes Ii, (Ii−Hii)−12, or (Ii−Hii)−1 respectively, c is a column vector, then v can be decomposed into the a weighted sum of independent χ21 distribution, where the weights are the eigenvalues of the n×n matrix G with elements Gij=g⊤iVgj
where
gi=s12(I−H)⊤iAiXi(X⊤X)−1c H=X(X⊤X)−1X⊤
(I−H)i corresponds to the rows of subject i.
So the degrees of freedom can be represented as ν=(∑iλi)2∑iλ2i
where λi,i=1,…,n are the eigenvalues of G. Bell and McCaffrey (2002) also suggests that V can be chosen as identify matrix, so Gij=g⊤igj.
Following Weighted Least Square Estimator, we can transform the original X into ˜x to use the above equations.
To avoid repeated computation of matrix Ai, H etc for different contrasts, we calculate and cache the following
G∗i=(I−H)⊤iAiXi(X⊤X)−1 which is a ∑imi×p matrix. With different contrasts, we need only calculate the following gi=G∗ic to obtain a ∑imi×1 matrix, G can be computed with gi.
To obtain the degrees of freedom, and to avoid eigen computation on a large matrix, we can use the following equation
ν=(∑iλi)2∑iλ2i=tr(G)2∑i∑jG2ij
The scale parameter is not used throughout the package.
The proof is as following
Let A has dimension p×q, B has dimension q×p tr(AB)=p∑i=1(AB)ii=p∑i=1q∑j=1AijBji
tr(BA)=q∑i=1(BA)ii=q∑i=1p∑j=1BijAji
so tr(AB)=tr(BA)
Following eigen decomposition, we have G=QΛQ⊤ where Λ is diagonal matrix, Q is orthogonal matrix.
Using the previous formula that tr(AB)=tr(BA), we have
tr(G)=tr(QΛQ⊤)=tr(ΛQ⊤Q)=tr(Λ)=∑i(λi)
tr(G⊤G)=tr(QΛQ⊤QΛQ⊤)=tr(Λ2Q⊤Q)=tr(Λ2)=∑i(λ2i)
and tr(G⊤G) can be further expressed as
tr(G⊤G)=∑i(G⊤G)ii=∑i∑jG⊤ijGji=∑i∑jG2ij
For multi-dimensional contrast we use the same technique for multi-dimensional contrast for asymptotic covariance.