# linear.hypothesis

0th

Percentile

##### Test Linear Hypothesis

Generic function for testing a linear hypothesis, and methods for linear models, generalized linear models, multivariate linear models, and other models that have methods for coef and vcov.

Keywords
models, regression, htest
##### Usage
linear.hypothesis(model, ...)

lht(model, ...)

## S3 method for class 'default':
linear.hypothesis(model, hypothesis.matrix, rhs=NULL,
test=c("Chisq", "F"), vcov.=NULL, verbose=FALSE, ...)

## S3 method for class 'lm':
linear.hypothesis(model, hypothesis.matrix, rhs=NULL,

## S3 method for class 'glm':
linear.hypothesis(model,  ...)

## S3 method for class 'mlm':
linear.hypothesis(model, hypothesis.matrix, rhs=NULL, SSPE, V,
test, idata, icontrasts=c("contr.sum", "contr.poly"), idesign, iterms,
P=NULL, title="", verbose=FALSE, ...)

## S3 method for class 'linear.hypothesis.mlm':
print(x, SSP=TRUE, SSPE=SSP,
digits=unlist(options("digits")), ...)
##### Arguments
model
fitted model object. The default method works for models for which the estimated parameters can be retrieved by coef and the corresponding estimated covariance matrix by vcov. See the Details for more informa
hypothesis.matrix
matrix (or vector) giving linear combinations of coefficients by rows, or a character vector giving the hypothesis in symbolic form (see Details).
rhs
right-hand-side vector for hypothesis, with as many entries as rows in the hypothesis matrix; can be omitted, in which case it defaults to a vector of zeroes. For a multivariate linear model, rhs is a matrix, defaulting to 0.
idata
an optional data frame giving a factor or factors defining the intra-subject model for multivariate repeated-measures data. See Details for an explanation of the intra-subject design and for further explanation of the other argume
icontrasts
names of contrast-generating functions to be applied by default to factors and ordered factors, respectively, in the within-subject data''; the contrasts must produce an intra-subject model matrix in which different terms are orthogonal.
idesign
a one-sided model formula using the data'' in idata and specifying the intra-subject design.
iterms
the quoted name of a term, or a vector of quoted names of terms, in the intra-subject design to be tested.
P
transformation matrix to be applied to the repeated measures in multivariate repeated-measures data; if NULL and no intra-subject model is specified, no response-transformation is applied; if an intra-subject model is
SSPE
in linear.hypothesis method for mlm objects: optional error sum-of-squares-and-products matrix; if missing, it is computed from the model. In print method for linear.hypothesis.mlm objec
test
character string, "F" or "Chisq", specifying whether to compute the finite-sample F statistic (with approximate F distribution) or the large-sample Chi-squared statistic (with asymptotic Chi-squared distribution).
title
an optional character string to label the output.
V
inverse of sum of squares and products of the model matrix; if missing it is computed from the model.
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.
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
verbose
If TRUE, the hypothesis matrix and right-hand-side vector (or matrix) are printed to standard output; if FALSE (the default), the hypothesis is only printed in symbolic form.
x
an object produced by linear.hypothesis.mlm.
SSP
if TRUE (the default), print the sum-of-squares and cross-products matrix for the hypothesis and the response-transformation matrix.
digits
minimum number of signficiant digits to print.
...
aruments to pass down.
##### Details

Computes either a finite sample F statistic or asymptotic Chi-squared statistic for carrying out a Wald-test-based comparison between a model and a linearly restricted model. The default method will work with any model object for which the coefficient vector can be retrieved by coef and the coefficient-covariance matrix by vcov (otherwise the argument vcov. has to be set explicitely). For computing the F statistic (but not the Chi-squared statistic) a df.residual method needs to be available. If a formula method exists, it is used for pretty printing. The method for "lm" objects calls the default method, but it changes the default test to "F", supports the convenience argument white.adjust (for backwards compatibility), and enhances the output by residual sums of squares. For "glm" objects just the default method is called (bypassing the "lm" method). The function lht also dispatches to linear.hypothesis. The hypothesis matrix can be supplied as a numeric matrix (or vector), the rows of which specify linear combinations of the model coefficients, which are tested equal to the corresponding entries in the righ-hand-side vector, which defaults to a vector of zeroes. Alternatively, the hypothesis can be specified symbolically as a character vector with one or more elements, each of which gives either a linear combination of coefficients, or a linear equation in the coefficients (i.e., with both a left and right side separated by an equals sign). Components of a linear expression or linear equation can consist of numeric constants, or numeric constants multiplying coefficient names (in which case the number precedes the coefficient, and may be separated from it by spaces or an asterisk); constants of 1 or -1 may be omitted. Spaces are always optional. Components are separated by plus or minus signs. See the examples below. A linear hypothesis for a multivariate linear model (i.e., an object of class "mlm") can optionally include an intra-subject transformation matrix for a repeated-measures design. If the intra-subject transformation is absent (the default), the multivariate test concerns all of the corresponding coefficients for the response variables. There are two ways to specify the transformation matrix for the repeated meaures:

1. The transformation matrix can be specified directly via thePargument.
2. A data frame can be provided defining the repeated-measures factor or factors viaidata, with default contrasts given by theicontrastsargument. An intra-subject model-matrix is generated from the one-sided formula specified by theidesignargument; columns of the model matrix corresponding to different terms in the intra-subject model must be orthogonal (as is insured by the default contrasts). Note that the contrasts given inicontrastscan be overridden by assigning specific contrasts to the factors inidata. The repeated-measures transformation matrix consists of the columns of the intra-subject model matrix corresponding to the term or terms initerms. In most instances, this will be the simpler approach, and indeed, most tests of interests can be generated automatically via theAnovafunction.

##### Value

• For a univariate model, 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. For a multivariate linear model, an object of class "linear.hypothesis.mlm", which contains sums-of-squares-and-product matrices for the hypothesis and for error, degrees of freedom for the hypothesis and error, and some other information. The returned object normally would be printed.

##### References

Fox, J. (1997) Applied Regression, Linear Models, and Related Methods. Sage. Hand, D. J., and Taylor, C. C. (1987) Multivariate Analysis of Variance and Repeated Measures: A Practical Approach for Behavioural Scientists. Chapman and Hall. O'Brien, R. G., and Kaiser, M. K. (1985) MANOVA method for analyzing repeated measures designs: An extensive primer. Psychological Bulletin 97, 316--333.

anova, Anova, waldtest, hccm, vcovHC, vcovHAC, coef, vcov

##### Aliases
• linear.hypothesis
• lht
• linear.hypothesis.lm
• linear.hypothesis.glm
• linear.hypothesis.mlm
• linear.hypothesis.default
• print.linear.hypothesis.mlm
##### Examples
mod.davis <- lm(weight ~ repwt, data=Davis)

## the following are equivalent:
linear.hypothesis(mod.davis, diag(2), c(0,1))
linear.hypothesis(mod.davis, c("(Intercept) = 0", "repwt = 1"))
linear.hypothesis(mod.davis, c("(Intercept)", "repwt"), c(0,1))
linear.hypothesis(mod.davis, c("(Intercept)", "repwt = 1"))

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

## the following are equivalent:
## use HC3 standard errors via white.adjust option
linear.hypothesis(mod.davis, c("(Intercept) = 0", "repwt = 1"),
## covariance matrix *function*
linear.hypothesis(mod.davis, c("(Intercept) = 0", "repwt = 1"), vcov = hccm)
## covariance matrix *estimate*
linear.hypothesis(mod.davis, c("(Intercept) = 0", "repwt = 1"),
vcov = hccm(mod.davis, type = "hc3"))

mod.duncan <- lm(prestige ~ income + education, data=Duncan)

## the following are all equivalent:
linear.hypothesis(mod.duncan, "1*income - 1*education = 0")
linear.hypothesis(mod.duncan, "income = education")
linear.hypothesis(mod.duncan, "income - education")
linear.hypothesis(mod.duncan, "1income - 1education = 0")
linear.hypothesis(mod.duncan, "0 = 1*income - 1*education")
linear.hypothesis(mod.duncan, "income-education=0")
linear.hypothesis(mod.duncan, "1*income - 1*education + 1 = 1")
linear.hypothesis(mod.duncan, "2income = 2*education")

mod.duncan.2 <- lm(prestige ~ type*(income + education), data=Duncan)
coefs <- names(coef(mod.duncan.2))

## test against the null model (i.e., only the intercept is not set to 0)
linear.hypothesis(mod.duncan.2, coefs[-1])

## test all interaction coefficients equal to 0
linear.hypothesis(mod.duncan.2, coefs[grep(":", coefs)], verbose=TRUE)

## a multivariate linear model for repeated-measures data
## see ?OBrienKaiser for a description of the data set used in this example.

mod.ok <- lm(cbind(pre.1, pre.2, pre.3, pre.4, pre.5,
post.1, post.2, post.3, post.4, post.5,
fup.1, fup.2, fup.3, fup.4, fup.5) ~  treatment*gender,
data=OBrienKaiser)
coef(mod.ok)

## specify the model for the repeated measures:
phase <- factor(rep(c("pretest", "posttest", "followup"), c(5, 5, 5)),
levels=c("pretest", "posttest", "followup"))
hour <- ordered(rep(1:5, 3))
idata <- data.frame(phase, hour)
idata

## test the four-way interaction among the between-subject factors
## treatment and gender, and the intra-subject factors
## phase and hour

linear.hypothesis(mod.ok, c("treatment1:gender1", "treatment2:gender1"),
title="treatment:gender:phase:hour", idata=idata, idesign=~phase*hour,
iterms="phase:hour")
Documentation reproduced from package car, version 1.2-2, License: GPL version 2 or newer

### Community examples

Looks like there are no examples yet.