| test_contrast_gau | R Documentation |
Tests 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).
test_contrast_gau(y, C, c = NULL, p = 1L)
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 |
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
A list with class gau_contrast_test containing:
Inference method used ("wald").
Contrast matrix
Right-hand side vector
Estimated mean vector
Estimated value of C * mu
Wald test statistic
Degrees of freedom (number of contrasts)
P-value from chi-square distribution
Zimmerman, D.L. and Núñez-Antón, V. (2009). Antedependence Models for Longitudinal Data. Chapman & Hall/CRC. Chapter 7.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.