Re: [R] trigonometric regression

From: Duncan Murdoch <murdoch.duncan_at_gmail.com>
Date: Thu, 17 Jun 2010 06:18:35 -0400

William Simpson wrote:
> Suppose I do a trigonometric regression
> fit<-lm(y~ cf + sf)
> where cf and sf are the cos and sine components.
>
> b<-coef(fit)
> I have the fitted sine component b[2] and the cos component b[3].
> Doing summary(fit) gives me the p-values and SEs for b[2] and b[3].
>
> But I want the amplitude of the fitted waveform
> amp<-sqrt(b[2]^2+b[3]^2)
>
> Can someone please tell me how to get the p-value for amp?
>

"the p-value for amp" is ambiguous; p-values refer to tests, not functions. But let's assume you want to test whether amp = 0. Then this is achieved by an F test comparing the model with cf and sf versus one without it. You'll see it in summary(fit) at the bottom of the display. If you want to include other covariates in the model, you can use anova, e.g.

anova(lm(y ~ other), lm(y ~ cf + sf + other))

Duncan Murdoch



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. Received on Thu 17 Jun 2010 - 10:21:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 Jun 2010 - 16:20:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive