Skip to content
Prev 165516 / 398506 Next

Implementing a linear restriction in lm()

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: rvaradhan at jhmi.edu


----- Original Message -----
From: Serguei Kaniovski <Serguei.Kaniovski at wifo.ac.at>
Date: Wednesday, December 24, 2008 9:39 pm
Subject: [R] Implementing a linear restriction in lm()
To: r-help at stat.math.ethz.ch