Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

glh.test

Test a General Linear Hypothesis for a Regression Model


Description

Test, print, or summarize a general linear hypothesis for a regression model

Usage

glh.test(reg, cm, d=rep(0, nrow(cm)) )
## S3 method for class 'glh.test'
print(x, digits=4,...)
## S3 method for class 'glh.test'
summary(object, digits=4,...)

Arguments

reg

Regression model

cm

matrix . Each row specifies a linear combination of the coefficients

d

vector specifying the null hypothis values for each linear combination

x, object

glh.test object

digits

number of digits

...

optional parameters (ignored)

Details

Test the general linear hypothesis C %*% \hat{beta} == d for the regression model reg.

The test statistic is obtained from the formula:

F = (C Beta-hat - d)' ( C (X'X)^-1 C' ) (C Beta-hat - d) / r / ( SSE / (n-p) )

Under the null hypothesis, f will follow a F-distribution with r and n-p degrees of freedom.

Value

Object of class c("glh.test","htest") with elements:

call

Function call that created the object

statistic

F statistic

parameter

vector containing the numerator (r) and denominator (n-p) degrees of freedom

p.value

p-value

estimate

computed estimate for each row of cm

null.value

d

method

description of the method

data.name

name of the model given for reg

matrix

matrix specifying the general linear hypotheis (cm)

Note

When using treatment contrasts (the default) the first level of the factors are subsumed into the intercept term. The estimated model coefficients are then contrasts versus the first level. This should be taken into account when forming contrast matrixes, particularly when computing contrasts that include 'baseline' level of factors.

See the comparison with fit.contrast in the examples below.

Author(s)

Gregory R. Warnes greg@warnes.net

References

R.H. Myers, Classical and Modern Regression with Applications, 2nd Ed, 1990, p. 105

See Also

Examples

# fit a simple model
y <- rnorm(100)
x <-  cut(rnorm(100, mean=y, sd=0.25),c(-4,-1.5,0,1.5,4))
reg <- lm(y ~ x)
summary(reg)

# test both group 1 = group 2  and group 3 = group 4
# *Note the 0 in the column for the intercept term*

C <- rbind( c(0,-1,0,0), c(0,0,-1,1) )
ret <- glh.test(reg, C)
ret  # same as 'print(ret) '
summary(ret)

# To compute a contrast between the first and second level of the factor
# 'x' using 'fit.contrast' gives:

fit.contrast( reg, x,c(1,-1,0,0) )
	
# To test this same contrast using 'glh.test', use a contrast matrix
# with a zero coefficient for the intercept term.  See the Note section,
# above, for an explanation.

C <- rbind( c(0,-1,0,0) )
glh.test( reg, C )

gmodels

Various R Programming Tools for Model Fitting

v2.18.1
GPL-2
Authors
Gregory R. Warnes, Ben Bolker, Thomas Lumley, and Randall C Johnson. Contributions from Randall C. Johnson are Copyright (2005) SAIC-Frederick, Inc. Funded by the Intramural Research Program, of the NIH, National Cancer Institute, Center for Cancer Research under NCI Contract NO1-CO-12400.
Initial release
2018-06-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.