car (version 1.0-16)

linear.hypothesis: Test Linear Hypothesis

Description

Generic function for testing a linear hypothesis, and methods for fitted linear or generalized linear models.

Usage

linear.hypothesis(model, ...)

lht(...)

## S3 method for class 'lm':
linear.hypothesis(model, hypothesis.matrix, rhs=0, 
  summary.model=summary(model, corr = FALSE), 
  test=c("F", "Chisq"), vcov=NULL,
  white.adjust=FALSE, error.SS, error.df, ...)

## S3 method for class 'glm':
linear.hypothesis(model, hypothesis.matrix, rhs=0, 
  summary.model=summary(model, corr = FALSE),
  test=c("Chisq", "F"), vcov=NULL, error.df, ...)

Arguments

model
model object produced by lm or glm.
hypothesis.matrix
matrix (or vector) giving linear combinations of coefficients by rows.
rhs
right-hand-side vector for hypothesis, with as many entries as rows in hypothesis.matrix.
summary.model
a summary object for the model; usually specified only when linear.hypothesis is called from another function that has already computed the summary.
test
character specifying wether to compute the finite sample F statistic (with approximate F distribution) or the large sample Chi-squared statistic (with asymptotic Chi-squared distribution).
vcov
a function for estimating the covariance matrix of the regression coefficients, e.g., hccm or an estimated covariance matrix for model. See also white.adjust.
white.adjust
logical or character. Convenience interface to hccm (instead of using the argument vcov). Can be set either to a character specifying the type argument of hccm
error.SS
error sum of squares for the hypothesis; if not specified, will be taken from summary.model.
error.df
error degrees of freedom for the hypothesis; if not specified, will be taken from summary.model.
...
aruments to pass down.

Value

  • An object of class "anova" which contains the residual degrees of freedom in the model, the difference in degrees of freedom, Wald statistic (either "F" or "Chisq") and corresponding p value.

Details

Computes either a finite sample F statistic (default for "lm" objects) or asymptotic Chi-squared statistic (default for "glm" objects) for carrying out a Wald-test-based comparison between a model and a linearly restricted model.

References

Fox, J. (1997) Applied Regression, Linear Models, and Related Methods. Sage.

See Also

anova, Anova, hccm, waldtest

Examples

Run this code
data(Davis)
mod<-lm(weight~repwt, data=Davis)
linear.hypothesis(mod, diag(2), c(0,1))

## use asymptotic Chi-squared statistic
linear.hypothesis(mod, diag(2), c(0,1), test = "Chisq")

## use HC3 standard errors via
## white.adjust option
linear.hypothesis(mod, diag(2), c(0,1), white.adjust = TRUE)
## covariance matrix *function*
linear.hypothesis(mod, diag(2), c(0,1), vcov = hccm)
## covariance matrix *estimate*
linear.hypothesis(mod, diag(2), c(0,1), vcov = hccm(mod, type = "hc3"))

Run the code above in your browser using DataLab