[R] Plotting confidence bands around regression line

David Winsemius dwinsemius at comcast.net
Tue Aug 10 18:35:53 CEST 2010


On Aug 10, 2010, at 12:12 PM, Michal Figurski wrote:

> David,
>
> I would consider myself intermediate in R, but a beginner in  
> statistics. I need a formula that would allow me to calculate  
> confidence boundaries of the regression line given the slope,  
> intercept and their CIs (and *any* range).

For "ordinary regression" the CI's for prediction intervals are going  
to be much wider than the CI's for parameter estimates. In both cases  
they are quadratic functions that depend on the mean_x_hat and on  
s_hat^2 (used as an estimate of sigma^2). These formulae should be  
available in any basic regression text. I am sufficiently aware of my  
non-statistician status to know that I could not comment on whether  
naively applying those functions to estimates from another method  
would have validity.

-- 
David.
>
> Passing-Bablok regression doesn't yet exist in R - I am developing  
> it. Therefore I am sure there is no predict method for it ;)
>
> I believe I have provided sufficient data to address this problem,  
> but if that would help anyone, here is more:
>
> # data frame
> > a <- structure(list(x = c(0.1, 1.43, 4.21, 3.67, 3.23, 7.72, 5.99,  
> 9.16, 10.6, 9.84, 11.94, 12.03, 12.89, 11.26, 15.54, 15.58, 17.32,  
> 17.65, 19.52, 20.48, 20.44, 20.51, 22.27, 23.58, 25.83, 26.04,  
> 26.92, 28.44, 30.73, 28.78), y = c(1.08, 1.39, 1.84, 0.56, 7.23,  
> 4.91, 3.35, 7.09, 3.16, 8.98, 16.37, 7.46, 15.46, 23.2, 4.63, 11.13,  
> 15.68, 13.92, 26.44, 21.65, 21.01, 20.22, 22.69, 22.21, 23.6, 17.24,  
> 45.24, 30.09, 40, 49.6)), .Names = c("x", "y"), row.names = c(NA,  
> -30L), class = "data.frame")
>
> Then I run the regression procedure (in development - now part of  
> the 'MethComp' package):
> > print(PBreg(a))
>
> # And the result of the Passing-Bablok regression on this data frame:
>           Estimate      5%CI     95%CI
> Intercept -4.306197 -9.948438 -1.374663
> Slope      1.257584  1.052696  1.679290
>
> The original Passing & Bablok article on this method has an easy  
> prescription for CIs on coefficients, so I implemented that. Now I  
> need a way to calculate CI boundaries for individual points - this  
> may be a basic handbook stuff - I just don't know it (I'm not a  
> statistician). I would appreciate if anyone could point me to a  
> handbook or website where it is described.
>
> Regarding 2 - the predict method for 'nls' class currently *ignores*  
> the interval parameter - as it is stated in documentation.
>
> Regards
>
> --
> Michal J. Figurski, PhD
> HUP, Pathology & Laboratory Medicine
> Biomarker Research Laboratory
> 3400 Spruce St. 7 Maloney
> Philadelphia, PA 19104
> tel. (215) 662-3413
>
> On 2010-08-10 11:38, David Winsemius wrote:
>>
>> On Aug 10, 2010, at 11:23 AM, Michal Figurski wrote:
>>
>>> David,
>>>
>>> I may have stated my problem incorrectly - my problem is to *obtain
>>> the coordinates* for confidence boundary lines. As input data I have
>>> only CIs for slope and intercept.
>>
>> Wouldn't you also need to specify the range over which these  
>> estimates
>> might be valid and to offer the means for the X values? What level  
>> of R
>> knowledge are you at? You have provided no data or code. Many R  
>> methods
>> offer predict methods that return CI's.
>>

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list