Tom La Bone
2007-Nov-18 01:29 UTC
[R] Linear Regression with lm Forcing the Slope to Equal 1
Is there a way to do a linear regression with lm (having one predictor variable) and constrain the slope of the line to equal 1? Tom -- View this message in context: http://www.nabble.com/Linear-Regression-with-lm-Forcing-the-Slope-to-Equal-1-tf4828804.html#a13815432 Sent from the R help mailing list archive at Nabble.com.
Duncan Murdoch
2007-Nov-18 02:02 UTC
[R] Linear Regression with lm Forcing the Slope to Equal 1
On 17/11/2007 8:29 PM, Tom La Bone wrote:> Is there a way to do a linear regression with lm (having one predictor > variable) and constrain the slope of the line to equal 1? >You could use the offset parameter to do this, e.g. x <- 1:20 y <- x + rnorm(20) lm(y ~ 1, offset=x) Duncan Murdoch
Washington Leite Junger
2007-Nov-18 02:11 UTC
[R] Linear Regression with lm Forcing the Slope to Equal 1
or simply insert the offset term into the formula lm(y~offset(x)) Washington On 17/11/2007 8:29 PM, Tom La Bone wrote:> Is there a way to do a linear regression with lm (having one predictor > variable) and constrain the slope of the line to equal 1? >You could use the offset parameter to do this, e.g. x <- 1:20 y <- x + rnorm(20) lm(y ~ 1, offset=x) Duncan Murdoch ______________________________________________ R-help at 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. -- Washington Leite Junger wjunger at terra.com.br
Christofer
2007-Nov-18 03:15 UTC
[R] Linear Regression with lm Forcing the Slope to Equal 1
One way of doing I think is to do it by 'hand'. In ls we minimizes SSE w.r.t. mu and beta. However in your case, you can concentrate only on minimizing SSE w.r.t. beta Regards, -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Tom La Bone Sent: Sunday, November 18, 2007 7:00 AM To: r-help at r-project.org Subject: [R] Linear Regression with lm Forcing the Slope to Equal 1 Is there a way to do a linear regression with lm (having one predictor variable) and constrain the slope of the line to equal 1? Tom -- View this message in context: http://www.nabble.com/Linear-Regression-with-lm-Forcing-the-Slope-to-Equal-1 -tf4828804.html#a13815432 Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at 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.