Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

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
...............
share|improve this question
Isn't lwr and upr the confidence interval? For each of your new ind values, 3,5,0.25 respectively? – Spacedman Jan 16 '12 at 7:57
@Spacedman - well not exactly...I need the CI for ind not for the height ...because I am calculating the ind (the X) given a new value of the height. And I need the CI for the new X=(Y-beta0)/beta1 – agatha Jan 16 '12 at 10:02
@Spacedman- is it that value X +/- the standard error at 95 %CI ? – agatha Jan 16 '12 at 10:03

1 Answer

up vote 1 down vote accepted

You are looking for the so called calibration interval. You have to be careful with the exact question: is $Y$ a new observation and you are trying to estimate $X$, or are you looking for the point where the regression line reaches $Y$? The difference will determine whether you need to use the confidence interval of the regression line or its prediction interval. Since you are talking about the confidence interval of the line, I assume you are interested in the latter question.

The 95% confidence interval for the estimated $X$ will be given by the points where the $y=Y$ horizontal line intersects the lower and upper confidence bands of the regression line. So go through the lwr values, and check at which x value they crossed the $Y$, and similarly for the upr values. Depending on the sophistication you want, this can be done by just looking at the printout, or having R find the crossing point, or even using the uniroot function to find the point with arbitrary precision (you are using steps of 0.25, so that's your current precision).

share|improve this answer
Yes that is what I was looking for..I couldn't find it anywhere better explained. Thanks. – agatha Jan 16 '12 at 19:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.