Michal Figurski
2010-Aug-10 14:56 UTC
[R] Plotting confidence bands around regression line
Dear R-helpers and graphics gurus, I have two problems with plotting confidence bands: 1. First is relatively simple. I am using the Passing-Bablok procedure to obtain "unbiased" regression coefficients. This procedure yields the "a" & "b" coefficient values along with their confidence intervals. I then plot the raw data with the regression line, but I would like to add the confidence band for the line... and I can't figure out how to do it. In other words, given: Estimate 5%CI 95%CI Intercept -4.305562 -9.931152 -1.381792 Slope 1.257318 1.053025 1.678516 How to plot the regression line with confidence band? 2. Second problem is plotting confidence bands along fitted "nls" regression line. I tried "predict(nls.object, int='c')" - but doesn't work. Later I figured in the documentation that the 'int' parameter is currently ignored. I guess this means it's not a trivial thing to do. Does anyone have a suggestion on how to obtain confidence predictions for such a model? Please cc my email address when you reply. Thanks and best regards, -- Michal J. Figurski, PhD HUP, Pathology & Laboratory Medicine Biomarker Research Laboratory 3400 Spruce St. 7 Maloney Philadelphia, PA 19104 tel. (215) 662-3413
David Winsemius
2010-Aug-10 15:09 UTC
[R] Plotting confidence bands around regression line
On Aug 10, 2010, at 10:56 AM, Michal Figurski wrote:> Dear R-helpers and graphics gurus, > > I have two problems with plotting confidence bands: > > 1. First is relatively simple. I am using the Passing-Bablok > procedure to obtain "unbiased" regression coefficients. This > procedure yields the "a" & "b" coefficient values along with their > confidence intervals. I then plot the raw data with the regression > line, but I would like to add the confidence band for the line... > and I can't figure out how to do it. > > In other words, given: > > Estimate 5%CI 95%CI > Intercept -4.305562 -9.931152 -1.381792 > Slope 1.257318 1.053025 1.678516 > > How to plot the regression line with confidence band?Take a look at plotCI in either gplots or plotrix packages. Harrell's rms/Hmisc packages are nicely integrated with lattice and encourage you to create effective displays of models that remove simplistic linearity assumptions. -- David.> > 2. Second problem is plotting confidence bands along fitted "nls" > regression line. I tried "predict(nls.object, int='c')" - but > doesn't work. Later I figured in the documentation that the 'int' > parameter is currently ignored. I guess this means it's not a > trivial thing to do. Does anyone have a suggestion on how to obtain > confidence predictions for such a model? > > Please cc my email address when you reply. Thanks and best regards, > > -- > Michal J. Figurski, PhD > HUP, Pathology & Laboratory Medicine > Biomarker Research Laboratory > 3400 Spruce St. 7 Maloney > Philadelphia, PA 19104 > tel. (215) 662-3413 > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius, MD West Hartford, CT
>>> Frank Harrell <f.harrell at vanderbilt.edu> 11/08/2010 17:02:03 >>>> This problem seems to cry out for one of the many available robust > regression methods in R.Not sure that would be much more appropriate, although it would _appear_ to work. The P&B method is a sort of nonparametric/robust approach to an errors-in-variables problem, intended to provide an indication of consistency of results between two different measurement methods, often with similar error variance. So the aim is to handle the error-in-variable problem at least consistently, to avoid the bias that results from assuming no error in predictors. The M-estimator and related robust regression methods in things like MASS and robustbase don't handle errors in the predictors. Of course, with small errors in predictors that won't matter much; rlm and the like will be pretty much as defensible then as they ever are. But perhaps one could construct a more formal robust equivalent of error-in-variable regression by using a max likelihood functional relationship model with bivariate t (choosing arbitrarily low df) instead of bivariate gaussian errors? Unfortunately I haven't tried that, so no help beyond the thought ... Steve Ellison ******************************************************************* This email and any attachments are confidential. Any use...{{dropped:8}}
I may be missing something but I don't see how P&B handles errors in variables any differently than other regression methods that ignore this problem. Frank Frank E Harrell Jr Professor and Chairman School of Medicine Department of Biostatistics Vanderbilt University On Wed, 11 Aug 2010, S Ellison wrote:> > >>>> Frank Harrell <f.harrell at vanderbilt.edu> 11/08/2010 17:02:03 >>> > >> This problem seems to cry out for one of the many available robust >> regression methods in R. > > Not sure that would be much more appropriate, although it would > _appear_ to work. The P&B method is a sort of nonparametric/robust > approach to an errors-in-variables problem, intended to provide an > indication of consistency of results between two different measurement > methods, often with similar error variance. So the aim is to handle the > error-in-variable problem at least consistently, to avoid the bias that > results from assuming no error in predictors. The M-estimator and > related robust regression methods in things like MASS and robustbase > don't handle errors in the predictors. Of course, with small errors in > predictors that won't matter much; rlm and the like will be pretty much > as defensible then as they ever are. > > But perhaps one could construct a more formal robust equivalent of > error-in-variable regression by using a max likelihood functional > relationship model with bivariate t (choosing arbitrarily low df) > instead of bivariate gaussian errors? Unfortunately I haven't tried > that, so no help beyond the thought ... > > Steve Ellison > > ******************************************************************* > This email and any attachments are confidential. Any u...{{dropped:9}}