[R] fitting non linear data

Frank E Harrell Jr fharrell at virginia.edu
Wed May 22 15:16:34 CEST 2002

To factor in model uncertainty you might bootstrap a semiparametric regression.   The Hmisc library areg.boot function, using the default method of avas, develops a semiparametric additive model and uses the bootstrap for confidence bands for the transformations on predictor and response variables.  As an example I tried

f <- areg.boot(I(y) ~ x)   # don't transform y, optimally transform x
# The default y ~ x shows a lot of uncertainty in transformation of y for
# large y


avas Additive Regression Model

areg.boot(x = I(y) ~ x)

n= 8   p= 1 

Apparent R2 on transformed Y scale: 0.886
Bootstrap validated R2            : 0.683

Coefficients of standardized transformations:

    Intercept             x 
-1.503799e-16  1.087857e+00 


summary.areg.boot(obj = f)

Estimates based on 100 resamples

Values to which predictors are set when estimating
effects of other predictors:

I(y)    x 
 5.5  5.5 

Estimates of differences of effects on Median Y (from first X value),
and bootstrap standard errors of these differences.
Settings for X are shown as row headings.

Predictor: x 
x      Differences      S.E Lower 0.95 Upper 0.95         Z      Pr(|Z|)
  3.75    0.000000       NA         NA         NA        NA           NA
  5.50   -4.614057 1.268541  -7.100353  -2.127762 -3.637294 0.0002755177
  7.25   -7.144868 2.030195 -11.123978  -3.165758 -3.519300 0.0004326864

plot(f)  # see attached

I had to fix a small bug in the function to make this work.
In the plot, confidence bands are in black, individual bootstrap estimates are in red.

Frank Harrell

On Wed, 22 May 2002 12:21:45 +0200
gregory lefebvre <greggory.lefebvre at univ-rouen.fr> wrote:

> Hye every one, 
> My question will certainly seem stupid as I am quite a beginner in R.
> I would like to trace a curve which fits these two vectors:
>  x<-c( 2,3,4,5,6,7,8,10 )
>  y<-c( 20, 12, 8, 6, 5, 4.5, 4, 3.8)
> It seems to follow a non linear model.
> Could anyone help me because I could'nt find the answer I am looking for
> in the FAQs.
> In advance thank you for your time.
> G. Lefebvre
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

Frank E Harrell Jr              Prof. of Biostatistics & Statistics
Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences
U. Virginia School of Medicine  http://hesweb1.med.virginia.edu/biostat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: z.png
Type: image/png
Size: 11010 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20020522/85c3e3f3/z.png

More information about the R-help mailing list