WaldTest: Testing independent linear hypotheses using a Wald test

WaldTestR Documentation

Testing independent linear hypotheses using a Wald test

Description

Use a contrast matrix to test several linear hypotheses on the coefficients using a Wald test. The hypotheses are assumed to be independent of each other.

Usage

WaldTest(object, ...)

## S3 method for class 'gls'
WaldTest(object, C, b = rep(0, NROW(C)), df = NULL, ...)

## S3 method for class 'lme'
WaldTest(object, C, b = rep(0, NROW(C)), df = NULL, ...)

Arguments

object

a model. Currently only support lme objects.

...

not used.

C

a contrast matrix. Number of rows is the number of hypotheses. Number of columns should match the number of coefficients in the model.

b

a vector such that the hypothesis to test is: C * \beta = b where \beta are the model coefficients.

df

[optional] the degree of freedom associated to the variance of each coefficient.

Details

Denoting \beta the estimated model coefficients, Sigma their estimated variance covariance matrix, and t() the transpose operator, this function computes:

Cb = C * \beta

CSC = C * \Sigma * t(C)

t = \sqrt{Cb/diag(CSC)}

and compute the p.value using the Gaussian distribution (df=NULL) or a student's t-distribution. In such a case the degrees of freedom are computed using:

Cdf = C * df

This formula is probably a very crude approximation to the appropriate degrees of freedom of diag(CSC) (assuming they exists).

Examples

library(nlme)

## gls
fm1 <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), Ovary,
               correlation = corAR1(form = ~ 1 | Mare))

name.coef <- names(coef(fm1))
n.coef <- length(name.coef)
C <- matrix(0, nrow = n.coef, ncol = n.coef,
            dimnames = list(name.coef, name.coef))
diag(C) <- 1
WaldTest(fm1, C)
summary(fm1)$tTable

## lme
fm2 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)

name.coef <- names(coef(fm2))
n.coef <- length(name.coef)
C <- matrix(0, nrow = n.coef, ncol = n.coef,
            dimnames = list(name.coef, name.coef))
diag(C) <- 1
WaldTest(fm2, C)
summary(fm2)$tTable


bozenne/butils documentation built on Oct. 14, 2023, 6:19 a.m.