Hi, You could use the "offset" argument in lm(). Here is an example:
set.seed(123) x <- runif(50) beta <- 1 y <- 2 + beta*x + rnorm(50) model1 <- lm (y ~ x) model2 <- lm (y ~ 1, offset=x) anova(model2, model1) Best, Ravi. ____________________________________________________________________ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu ----- Original Message ----- From: Serguei Kaniovski <serguei.kaniov...@wifo.ac.at> Date: Wednesday, December 24, 2008 9:39 pm Subject: [R] Implementing a linear restriction in lm() To: r-h...@stat.math.ethz.ch > > Dear All! > > I want to test a coeffcient restriction beta=1 in a univariate model > lm > (y~x). Entering > lm((y-x)~1) does not help since anova test requires the same dependent > variable. What is the right way to proceed? > > Thank you for your help and marry xmas, > Serguei Kaniovski > ________________________________________ > Austrian Institute of Economic Research (WIFO) > > P.O.Box 91 Tel.: +43-1-7982601-231 > 1103 Vienna, Austria Fax: +43-1-7989386 > > Mail: serguei.kaniov...@wifo.ac.at > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > > PLEASE do read the posting guide > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list 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.