[R] lm: how are polynomial functions interpreted?
Carl Witthoft
carl at witthoft.com
Mon Jan 12 23:57:55 CET 2009
Well..... *_* ,
I think it should have been clear that this was not a question for which
any code exists. In fact, I gave two very specific examples of function
calls. The entire point of my question was not "what's up with my
(putative) code and data " but rather to try to understand the
overarching philosophy of the way lm() treats the function it's given.
I do understand the sneaky ways to make it do a linear fit with or
without forcing the origin. And, sure, I could have run a data set thru
a bunch of different quadratic-like functions to try to see what happens.
Let me pick a more complicated example. The general case of a sin fit
might be Y = a + b*sin(d*x+phi) .(where, to be pedantic, x is the only
data input. All others are coefficients to be found)
If I try y<-lm(yin~I(sin(x))), what is the actual fit function? And so on.
That's why I was hoping for a more general explanation of what lm() does.
Charles C. Berry wrote:
> On Mon, 12 Jan 2009, cgw at witthoft.com wrote:
>
> [nothing deleted]
>
> matplot(1:100, lm(rnorm(100)~poly(1:100,4),x=T)$x ) # for example
>
>>
>> ______________________________________________
>> 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
>
> Ahem!
>
>> and provide commented, minimal, self-contained, reproducible code.
> ......^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Charles C. Berry (858) 534-2098
> Dept of Family/Preventive
> Medicine
> E mailto:cberry at tajo.ucsd.edu UC San Diego
> http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
>
>
>
More information about the R-help
mailing list