[R] Closest fit data to a particular formula

Bert Gunter gunter.berton at gene.com
Tue Nov 20 07:27:43 CET 2012


But ...

On Mon, Nov 19, 2012 at 9:23 PM, Jeff Newmiller
<jdnewmil at dcn.davis.ca.us> wrote:
> Try using the lm function:

... Better yet, post to a statistics list, like
stats.stackexchange.com, as the questions appear primarily
statistical, and not R related.

Incidentally, loess() is specifically designed to deal with
"outliers," so if you think it does not, you need to study up on how
it works. You may also wish to consult the CRAN Robust task view,
which discusses many more R packages and functions to fit models in
the presence of "unusual values". But you probably should do so only
after you've had more guidance from a statistical list. Or perhaps you
should consult your local statistician for some advice,,,

-- Bert

>
> ?lm
> ---------------------------------------------------------------------------
> Jeff Newmiller                        The     .....       .....  Go Live...
> DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
>                                       Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
> /Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
> ---------------------------------------------------------------------------
> Sent from my phone. Please excuse my brevity.
>
> David <david at serendipityscience.com> wrote:
>
>>R folks,
>>  I am somewhat new to R and have started to stumble...
>>I have a set of data that I am trying to model, so that I can predict
>>on
>>a much larger set - and I have been using loess to get a model.. but it
>>is
>>not what I would like to see.  For instance, I know from the nature of
>>the
>>data that the shape of this line should only decrease, and yet the
>>loess is
>>being affected by the sample outliers at 1100.  What I am interested in
>>is
>>the "best fit" of the sample data to a formula that I supply it.
>>Reading
>>the documentation for loess - it seems that I can do this by supplying
>>a
>>formula.. but I have not had much luck.  Perhaps I am reading the
>>documentation incorrectly.  Here is my current loess line code:
>>
>>mg.lo = loess(y ~ x, mg, span=0.25)
>>mg$x_c <- predict(mg.lo)
>>
>>which produces a curve like the attached file loess_curve.png.
>>
>>and I would like to have a curve "something like" the arccot in the
>>attached file arccotangent.png (from wikipedia), but all x values are
>>positive - meaning just the best fit of the sample data to that type of
>>curve.. starts high and finishes low but doesn't go below zero and only
>>decreases.  Looking at the arccot(x) definition I can see it as:
>>
>>arccot x = pi/2 - atan(x)
>>
>>So I tried to apply variations of that to the loess first "formula"
>>parameter with underwhelming results.
>>
>>Am I even remotely on the right track?  Can loess get me there?  If not
>>-
>>another function?
>>
>>Any and all comments would be greatly appreciated.
>>
>>David
>>
>>
>>------------------------------------------------------------------------
>>
>>______________________________________________
>>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.
>
> ______________________________________________
> 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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm




More information about the R-help mailing list