[R] F-test where the coefficients in the H_0 is nonzero
Annaert Jan
j@n@@nn@ert @end|ng |rom u@ntwerpen@be
Fri Aug 3 07:54:36 CEST 2018
You can easily test linear restrictions using the function linearHypothesis() from the car package.
There are several ways to set up the null hypothesis, but a straightforward one here is:
> library(car)
> x <- rnorm(10)
> y <- x+rnorm(10)
> linearHypothesis(lm(y~x), c("(Intercept)=0", "x=1"))
Linear hypothesis test
Hypothesis:
(Intercept) = 0
x = 1
Model 1: restricted model
Model 2: y ~ x
Res.Df RSS Df Sum of Sq F Pr(>F)
1 10 10.6218
2 8 9.0001 2 1.6217 0.7207 0.5155
Jan
From: R-help <r-help-bounces using r-project.org> on behalf of John <miaojpm using gmail.com>
Date: Thursday, 2 August 2018 at 10:44
To: r-help <r-help using r-project.org>
Subject: [R] F-test where the coefficients in the H_0 is nonzero
Hi,
I try to run the regression
y = beta_0 + beta_1 x
and test H_0: (beta_0, beta_1) =(0,1) against H_1: H_0 is false
I believe I can run the regression
(y-x) = beta_0 +beta_1‘ x
and do the regular F-test (using lm functio) where the hypothesized
coefficients are all zero.
Is there any function in R that deal with the case where the
coefficients are nonzero?
John
[[alternative HTML version deleted]]
______________________________________________
mailto:R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list