I followed the post by Max but doesn't seem to understand how to apply the solution given by Alejandro to a different regression equation with form in lm(y~x1+x2).
Below are data for you to reproduce and what I did.
y=c(139.31449, 105.17776, 105.38411, 99.27608, 92.29064, 91.55114, 84.44251, 78.40453, 74.66656, 73.33242, 72.42429, 77.08666)
x1=c(0.04, 0.00, 0.00, 0.00, 0.00, 0.00, 0.04, 0.00, 0.00, 0.00, 0.00, 0.00)
x2=c(0.00, 0.08, 0.10, 0.12, 0.15, 0.20, 0.00, 0.08, 0.10, 0.12, 0.15, 0.20)
lm1 <- lm(y ~ x1+x2)
newx = seq(min(x1+x2),max(x1+x2),by = 0.05)
conf_interval <- predict(lm1, newdata=data.frame(x=newx), interval="confidence",
level = 0.95)
plot(x1+x2, y, xlab="x", ylab="y")
abline(lm1, col="lightblue")
matlines(newx, conf_interval[,2:3], col = "blue", lty=2)
I'm not sure if I'm doing the right thing for newx. I had issue with adding regression line or I shouldn't use abline? R not running conf_interval properly as well.
I tried looking for similar topic to mine but struggle to find one. Can someone help please? Thanks.