[R] regression with a*cos(angle+phi)+b
Peter Dalgaard
P.Dalgaard at biostat.ku.dk
Mon Nov 30 14:12:05 CET 2009
Jorge Ivan Velez wrote:
> Good morning Markus,
>
> Perhaps ?nls might be useful in this case.
Or consult a compendium and realize that both formulas actually fit the
same class of shifted sinusoidals... It holds that
cos(v+phi) = cos phi cos v - sin phi sin v
so you can fairly easily find A and phi from the coefficients in
lm(a~cos+sin). The only reason to use nls is that it is a nonlinear
transformation, so a profile-based confidence interval might be more
accurate than one based on the delta method.
>
> HTH,
> Jorge
>
>
> On Mon, Nov 30, 2009 at 7:19 AM, Markus H�ge <> wrote:
>
>> Hello,
>>
>> the only thing I found to fit a sin/cos is s.th like lm(a~cos+sin) But
>> this is not what I want.
>> I have a magnitude which is sinusoidal with offset and it doesn't start
>> at phi=0.
>>
>> The data is:
>>
>> angle<-c(0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180)
>>
>> Voltage<-c(-45.07, -45.24, -43.61, -40.78, -36.48, -30.92, -23.83,
>> -15.95, -7.53, 1.06, 11.24,19.85, 27.00, 35.00, 42.90, 49.41,
>> 54.62, 58.54, 60.90)
>>
>> I need an regression with Voltage=A*cos(angle+phi)+B.
>> How does this work? With lm or shall I use twice Fourier?
>>
>> thanks
>>
>> Markus
>>
>> ______________________________________________
>> 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.
>>
>
> [[alternative HTML version deleted]]
>
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> 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.
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list