Try using the lm function:
?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.