Given a regression model:
y = b0 + b1(x)
where both x and y are continuous.
After fitting the model, I'd like to estimate the predicted mean and 95%CI of y when x is at a certain value, say, 100.
In Stata, it can be achieved with margins:
reg y x
margins, at (x = 100)
In SAS, it can be done with estimate:
proc glm;
model y = x / clparm solution;
estimate "Test x = 100" intercept 1 x 100;
run;
My question is: how to achieve the same action in R? I tried the lsmeans
package but it seems it will not work if I don't have any categorical variables in my model.
predict(fit,newdata=data.frame(x=100),interval="confidence")
(I don't agree with @thelatemail's advice that prediction intervals are preferred; prediction intervals are specified if you want to allow for the residual error ...)