Dear Ross, lm(y ~ 0 + offset(x)) will do the trick, but the resulting model has no coefficient estimates and thus can't be used with abline(). You can, e.g., get predictions from the model, but I'm not sure what real use it will be to you.
I hope this helps, John -------------------------------- John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of RCulloch > Sent: September-13-11 7:03 AM > To: r-help@r-project.org > Subject: [R] Force regression line to a 1:1 relationship > > Hello, > > I appreciate this is likely to be an easy question. I am trying to > obtain the residuals from a linear regression where the line is forced > to have a > 1:1 relationship. > > An example of the data: > > A<-c(0.9803922, 1.3850416, 0.8241758, 0.0000000, 0.4672897, 1.1904762, > 0.0000000, 0.9456265, > 1.5151515) > B<-c(1.3229572, 1.9471488, 1.3182674, 0.7007708, 1.0185740, 1.0268562, > 0.8695652, 0.3016591, 1.9667171) > > plot(A, B, ylim=c(0,2), xlim=c(0,2)) > abline(0,1, col="lightgrey", lty="dashed",lwd=2)#1:1 relationship = > what I want to use in the lm() > > #Normal regression > AB<-lm(A~B) > > #plot regression line > abline(lm(AB)) > > > How can I force the regression to have a 1:1 relationship, I assume it > is to do with offset() but I have somewhat fried my brain trying > numerous variations and I am not convinced any are correct. I was also > hoping the plot function would show me that the calculation is correct, > but any time I use the offset() command there is no line plotted? > > Any hints or tips would be much appreciated! > > Ross > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Force- > regression-line-to-a-1-1-relationship-tp3809733p3809733.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. ______________________________________________ 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.