Skip to content
Back to formatted view

Raw Message

Message-ID: <f5bef5b03d6.495370f5@johnshopkins.edu>
Date: 2008-12-25T16:39:33Z
From: Ravi Varadhan
Subject: Implementing a linear restriction in lm()
In-Reply-To: <OFE781A832.166F3BD4-ONC1257529.00417BEE-C1257529.00417BF1@wsr.ac.at>

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


>  
>  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.Kaniovski at wifo.ac.at
>  
>  	[[alternative HTML version deleted]]
>   
> ______________________________________________
>  R-help at r-project.org mailing list
>  
>  PLEASE do read the posting guide 
>  and provide commented, minimal, self-contained, reproducible code.