j|ox @end|ng |rom mcm@@ter@c@
Thu Sep 17 15:55:24 CEST 2020
On 2020-09-17 9:07 a.m., Johan Lassen wrote:
> Dear R-users,
> I am using the R-function "linearHypothesis" to test if the sum of all
> parameters, but the intercept, in a multiple linear regression is different
> from zero.
> I wonder if it is statistically valid to use the linearHypothesis-function
> for this?
Yes, assuming of course that the hypothesis makes sense.
> Below is a reproducible example in R. A multiple regression: y =
> It seems to me that the linearHypothesis function does the calculation as
> an F-test on the extra residuals when going from the starting model to a
> 'subset' model, although all variables in the 'subset' model differ from
> the variables in the starting model.
> I normally think of a subset model as a model built on the same input data
> as the starting model but one variable.
> Hence, is this a valid calculation?
First, linearHypothesis() doesn't literally fit alternative models, but
rather tests the linear hypothesis directly from the coefficient
estimates and their covariance matrix. The test is standard -- look at
the references in ?linearHypothesis or most texts on linear models.
Second, formulating the hypothesis using alternative models is also
legitimate, since the second model is a restricted version of the first.
> Thanks in advance,Johan
> # R-code:
> y <-
> data <-
> model <- lm(y~t0+t1+t2+t3+t4+0,data=data)
You need not supply the constant regressor t0 explicitly and suppress
the intercept -- you'd get the same test from linearHypothesis() for
test = "F" is the default.
> # Reproduce the result from linearHypothesis:
> # beta1+beta2+beta3+beta4=0 -> beta4=-(beta1+beta2+beta3) ->
> # y=beta0+beta1*t1+beta2*t2+beta3*t3-(beta1+beta2+beta3)*t4
> # y = beta0'+beta1'*(t1-t4)+beta2'*(t2-t4)+beta3'*(t3-t4)
> data$t1 <- data$t1-data$t4
> data$t2 <- data$t2-data$t4
> data$t3 <- data$t3-data$t4
> model_reduced <- lm(y~t0+t1+t2+t3+0,data=data)
Yes, this is equivalent to the test performed by linearHypothesis()
using the coefficients and their covariances from the original model.
I hope this helps,
John Fox, Professor Emeritus
Hamilton, Ontario, Canada
More information about the R-help