[R] lm: how are polynomial functions interpreted?

roger koenker rkoenker at uiuc.edu
Tue Jan 13 00:13:03 CET 2009


[E] Y = a + b*sin(d*x+phi)

isn't a linear model and therefore can't be estimated with lm()  --  
you will need
some heavier artillery.  Linear as in lm() means "linear in parameters."

(As it happens, I'm adapting Gordon Smyth's pronyfreq S code for the  
above
problem this afternoon, and have been wondering why someone else hasn't
already done this?  Any clues?


url:    www.econ.uiuc.edu/~roger            Roger Koenker
email    rkoenker at uiuc.edu            Department of Economics
vox:     217-333-4558                University of Illinois
fax:       217-244-6678                Champaign, IL 61820



On Jan 12, 2009, at 4:57 PM, Carl Witthoft wrote:

> 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
>>
>
> ______________________________________________
> 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.




More information about the R-help mailing list