# [R] F-test where the coefficients in the H_0 is nonzero

Mark Leeds m@rk|eed@2 @end|ng |rom gm@||@com
Thu Aug 9 11:10:27 CEST 2018

```Hi: the F-test is a joint hypothesis ( I never used that function from the
car package but it sounds like it is )  and the t-statistics
that come  out of a  regression are "conditional" in the sense that they
test the significance of one coefficient given the other so you wouldn't
expect the two outputs to be the same.

On Thu, Aug 9, 2018 at 4:58 AM, John <miaojpm using gmail.com> wrote:

> Hi,
>
>    I try to run the same f-test by lm (with summary) and the function
> "linearHypothesis" in car package. Why are the results (p-values for the
> f-test) different?
>
>
> > df1<-data.frame(x=c(2,3,4), y=c(7,6,8))
> > lm1<-lm(y~x, df1)
> > lm1
>
> Call:
> lm(formula = y ~ x, data = df1)
>
> Coefficients:
> (Intercept)            x
>         5.5          0.5
>
> > summary(lm1)
>
> Call:
> lm(formula = y ~ x, data = df1)
>
> Residuals:
>    1    2    3
>  0.5 -1.0  0.5
>
> Coefficients:
>             Estimate Std. Error t value Pr(>|t|)
> (Intercept)    5.500      2.693   2.043    0.290
> x              0.500      0.866   0.577    0.667
>
> Residual standard error: 1.225 on 1 degrees of freedom
> Multiple R-squared:   0.25, Adjusted R-squared:   -0.5
> F-statistic: 0.3333 on 1 and 1 DF,  p-value: 0.6667
>
> > linearHypothesis(lm1, c("(Intercept)=0", "x=0"))
> Linear hypothesis test
>
> Hypothesis:
> (Intercept) = 0
> x = 0
>
> Model 1: restricted model
> Model 2: y ~ x
>
>   Res.Df   RSS Df Sum of Sq      F Pr(>F)
> 1      3 149.0
> 2      1   1.5  2     147.5 49.167 0.1003
>
> 2018-08-03 13:54 GMT+08:00 Annaert Jan <jan.annaert using uantwerpen.be>:
>
> > 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.
> >
> >
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>

[[alternative HTML version deleted]]

```