Skip to content
Prev 155662 / 398502 Next

re flecting a line

Is something like this what you are looking for?

x <- 1:100
y <- 10 + x + 10*rnorm(100)

plot(y~x)
fit1.lm <- lm(y~x)
abline(fit1.lm, col='blue')
fit2.lm <- lm(x~y)
abline(-coef(fit2.lm)[1]/coef(fit2.lm)[2], 1/coef(fit2.lm)[2], col='red')


Hope this is helpful,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA  98504-5204