I want to create a linear model of y vs x and use it to find a confidence interval for y given a observed value of x.
So I created some samples:
x=rnorm(100,2)
y=rnorm(100,2)
and created the linear model:
bbbb=lm(y~x)
But when I use predict to create the confidence intervals, it gives me a bunch list of confidence intervals rather than a single one?
predict(bbbb,x=2,interval="confidence")
returns:
...
51 2.188294 1.949615 2.426973
52 2.189329 1.932474 2.446183
53 2.176816 1.950111 2.403521
54 2.183961 1.998136 2.369786
...
How can I make it return just one confidence interval for y when x=2?
predict()...) - Gavin Simpson