waldTest: Wald Chi-Square Test

View source: R/waldTest.R

waldTestR Documentation

Wald Chi-Square Test

Description

This function implements the Wald chi-square test on a Kx1 parameter vector theta. The test assumes that thetaHat, a consistent estimator of theta such as MLE, is asymptotically normal with mean theta and covariance matrix Sigma. The function can implement 1 test on theta as well as multiple, Q, tests jointly on theta.

Usage

waldTest(R, thetaHat, Sigma, r = 0, L = NULL)

Arguments

R

A QxK matrix of known coefficients depending on how the test is to be carried out.

thetaHat

An estimate of theta.

Sigma

An estimated covariance matrix for thetaHat.

r

A Qx1 matrix of hypothesized values.

L

A character string to be used as a name of the test. When NULL, "L" will be used.

Details

Suppose that Q tests are to be performed jointly on the K by 1 parameter vector theta. Let R be a QxK matrix of known coefficients such as 0, 1, and -1, and r be a Qx1 matrix of hypothesized values. The hypotheses are H0: R\theta = r vs. H1: R\theta != r. The test statistic has a chi-square distribution with Q degrees of freedom (Buse, 1982; Agresti, 2002).

Value

A data.frame object of the Wald test results.

References

Agresti A. (2002). Categorical Data Analysis (2nd ed.). Wiley. ISBN 0471360937.

Buse A. (1982). The Likelihood Ratio, Wald, and Lagrange Multiplier Tests: An Expository Note. The American Statistician, 36:153-157.

Examples


library(groupTesting)

## Example 1
# Parameter: p (proportion)
MLE <- 0.42
Var <- 0.016
# (a) Test  H0: p = 0.50  vs. H1: p != 0.50
R <- matrix(1, nrow=1, ncol=1)
p0 <- 0.50
waldTest( R=R, thetaHat=MLE, r=p0, Sigma=Var ) 

## Example 2
# Parameter: beta = (beta1, beta2), regression coefficients
MLE <- c(1.09, 2.95)
Cov <- rbind(c(0.21, -0.27), 
             c(-0.27, 0.66))
# (a) Test  H0: beta1 = beta2  vs. H1: beta1 != beta2
R <- rbind(c(1,-1))
waldTest( R=R, thetaHat=MLE, r=0, Sigma=Cov, L="1 vs 2" )

# (b) Test  H0: beta1 = 0  vs. H1: beta1 != 0
R <- rbind(c(1,0))
waldTest( R=R, thetaHat=MLE, r=0, Sigma=Cov )

## Example 3
# Parameter: beta = (beta0, beta1, beta2)
MLE <- c(-3.05, 1.99, 0.93)
Cov <- rbind(c( 0.045, -0.022, -0.034),
             c(-0.022,  0.032,  0.008),
             c(-0.034,  0.008,  0.048))

# Performing simultaneous test:
# H0: beta0  = -3, H0: beta1  = 2, H0: beta2  = 1
# H1: beta0 != -3, H1: beta1 != 2, H1: beta2 != 1
R <- rbind(c(1,0,0), 
           c(0,1,0), 
           c(0,0,1))
r <- matrix( c(-3,2,1), nrow=3 )
waldTest( R=R, thetaHat=MLE, r=r, Sigma=Cov)


groupTesting documentation built on Nov. 6, 2023, 9:06 a.m.