Considering a simple linear regression model Y= beta0+beta1 x X, with beta0 and beta1 computed, I have to estimate the expected X given a new Y and 95% confidence intervals. I used the formula X=(Y-beta0)/slope. How can I compute in R the 95% interval for the calculated value of ind, given a new value of the height?
head(df)
ind height
1 4.27 174
2 3.60 159
3 3.61 175
summary(lm(df$ind~df$height))
Call:
lm(formula = df$ind ~ df$height)
Residuals:
Min 1Q Median 3Q Max
-0.56263 -0.27596 0.03866 0.26632 0.55440
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.968895 1.512371 -0.641 0.52903
df$height 0.027871 0.008985 3.102 0.00562 **
Residual standard error: 0.3287 on 20 degrees of freedom
Multiple R-squared: 0.3248, Adjusted R-squared: 0.2911
F-statistic: 9.622 on 1 and 20 DF, p-value: 0.005621
#
I tried:
pred.frame <- data.frame(ind=seq(3,5,0.25))
predict(bclm,int="c",level=0.95,data=pred.frame)
fit lwr upr
1 174.5780 169.3146 179.8414
2 166.7696 163.6419 169.8973
3 166.8862 163.7806 169.9917
...............