knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(mmrm)
For determining the degrees of freedom (DF) required for the testing of fixed effects, one option is to use the "between-within" method, originally proposed by @schluchter1990small as a small-sample adjustment.
Using this method, the DF are determined by the grouping level at which the term is estimated. Generally, assuming $G$ levels of grouping:
$DF_g=N_g-(N_{g-1}+p_g), g=1, ..., G+1$
where $N_g$ is the number of groups at the $g$-th grouping level and $p_g$ is the number of parameters estimated at that level.
$N_0=1$ if the model includes an intercept term and $N_0=0$ otherwise. Note however that the DF for the intercept term itself (when it is included) are calculated at the $G+1$ level, i.e. for the intercept we use $DF_{G+1}$ degrees of freedom.
We note that general contrasts $C\beta$ have not been considered in the literature so far. Here we therefore use a pragmatic approach and define that for a general contrast matrix $C$ we take the minimum DF across the involved coefficients as the DF.
In our case of an MMRM (with only fixed effect terms), there is only a single grouping level (subject), so $G=1$. This means there are 3 potential "levels" of parameters (@galecki2013linear):
Let's look at a concrete example and what the "between-within" degrees of freedom method gives as results:
fit <- mmrm( formula = FEV1 ~ RACE + SEX + ARMCD * AVISIT + us(AVISIT | USUBJID), data = fev_data, control = mmrm_control(method = "Between-Within") ) summary(fit)
Let's try to calculate the degrees of freedom manually now.
In fev_data
there are 197 subjects with at least one non-missing FEV1
observation, and 537 non-missing observations in total. Therefore we obtain the following numbers of groups $N_g$ at the levels $g=1,2$:
And we note that $N_0 = 1$ because we use an intercept term.
Now let's look at the design matrix:
head(model.matrix(fit), 1)
Leaving the intercept term aside, we therefore have the following number of parameters for the corresponding effects:
RACE
: 2SEX
: 1ARMCD
: 1AVISIT
: 3ARMCD:AVISIT
: 3In the model above, RACE
, SEX
and ARMCD
are between-subjects effects and belong to level 1; they do not vary within subject across the repeated observations.
On the other hand, AVISIT
is a within-subject effect; it represents study visit, so naturally its value changes over repeated observations for each subject. Similarly, the interaction of ARMCD
and AVISIT
also belongs to level 2.
Therefore we obtain the following numbers of parameters $p_g$ at the levels $g=1,2$:
And we obtain therefore the degrees of freedom $DF_g$ at the levels $g=1,2$:
So we can finally see that those degrees of freedom are exactly as displayed in the summary table above.
The implementation described above is not identical to that of SAS. Differences include:
CONTRAST
/ESTIMATE
statement is used to define the DF for general contrasts.Code contributions for adding the SAS version of between-within degrees of freedom to the mmrm
package are welcome!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.