Test linear hypotheses on the mean under antedependence
Source:R/lrt_mean_gau.R
test_contrast_gau.RdTests the null hypothesis C * mu = c for a specified contrast matrix C and vector c, under an AD(p) covariance structure. This implements Theorem 7.2 of Zimmerman & Núñez-Antón (2009).
Arguments
- y
Numeric matrix with n_subjects rows and n_time columns.
- C
Contrast matrix with c rows and n_time columns, where c is the number of contrasts being tested. Rows must be linearly independent.
- c
Right-hand side vector of length equal to nrow(C). Default is a vector of zeros.
- p
Antedependence order of the covariance structure. This is the same order parameter named
orderinfit_gau.
Value
A list with class gau_contrast_test containing:
- method
Inference method used (
"wald").- C
Contrast matrix
- c
Right-hand side vector
- mu_hat
Estimated mean vector
- contrast_est
Estimated value of C * mu
- statistic
Wald test statistic
- df
Degrees of freedom (number of contrasts)
- p_value
P-value from chi-square distribution
Details
The Wald test statistic (Theorem 7.2) is: $$(C\bar{Y} - c)^T (C \hat{\Sigma} C^T)^{-1} (C\bar{Y} - c)$$
where \(\hat{\Sigma}\) is the REML estimator of the covariance matrix under the AD(p) model.
Common examples include:
Testing if mean is constant: C is the first-difference matrix
Testing for linear trend: C tests deviations from linearity
References
Zimmerman, D.L. and Núñez-Antón, V. (2009). Antedependence Models for Longitudinal Data. Chapman & Hall/CRC. Chapter 7.
Examples
if (FALSE) { # \dontrun{
y <- simulate_gau(n_subjects = 50, n_time = 5, order = 1)
# Test if mean is constant (all differences = 0)
# C is 4x5 matrix of first differences
C <- matrix(0, nrow = 4, ncol = 5)
for (i in 1:4) {
C[i, i] <- 1
C[i, i+1] <- -1
}
test <- test_contrast_gau(y, C = C, p = 1)
print(test)
} # }