[R] F-test where the coefficients in the H_0 is nonzero
peter dalgaard
pd@|gd @end|ng |rom gm@||@com
Thu Aug 2 11:06:15 CEST 2018
This should do it:
> x <- rnorm(10)
> y <- x+rnorm(10)
> fit1 <- lm(y~x)
> fit2 <- lm(y~-1 + offset(0 + 1 * x))
> anova(fit2, fit1)
Analysis of Variance Table
Model 1: y ~ -1 + offset(0 + 1 * x)
Model 2: y ~ x
Res.Df RSS Df Sum of Sq F Pr(>F)
1 10 10.6381
2 8 7.8096 2 2.8285 1.4487 0.2904
> On 2 Aug 2018, at 10:30 , John <miaojpm using gmail.com> wrote:
>
> 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]]
>
> ______________________________________________
> 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.
--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes using cbs.dk Priv: PDalgd using gmail.com
More information about the R-help
mailing list