So I want to plot this:
lmfit = lm (y ~ a + b)
but, \"b\" only has the values of zero and one. So, I want to plot two separate regre
You might want to consider using predict(...)
with b=0
and b=1
, as follows. Since you didn't provide any data, I'm using the built-in mtcars
dataset.
lmfit <- lm(mpg~wt+cyl,mtcars)
plot(mpg~wt,mtcars,col=mtcars$cyl,pch=20)
curve(predict(lmfit,newdata=data.frame(wt=x,cyl=4)),col=4,add=T)
curve(predict(lmfit,newdata=data.frame(wt=x,cyl=6)),col=6,add=T)
curve(predict(lmfit,newdata=data.frame(wt=x,cyl=8)),col=8,add=T)