Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Phase difference between different sine waves
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Phase difference between different sine waves
Date
Mon, 24 Mar 2014 12:42:39 +0000
I imagine the simplest possible set-up unless you tell me otherwise.
Given an angle theta and a phase phi
sin(theta + phi) = sin theta cos phi + cos theta sin phi
so if you are regressing on variables -sine- and -cosine-, which are
functions of theta, then
cos phi is (estimated by) the coefficient of -sine- and sin phi is
(estimated by) the coefficient of -cosine-
and so after -regress- (or equivalent
phi = arctan(sin phi/cos phi) = arctan(_b[cosine]/_b[sine])
Stata, like almost any other software, will return an angle in
radians. You will presumably want to convert that back to some
fraction of a year.
As a phase (difference) corresponds to a horizontal shift, you can
represent that as a difference in time, but (depending very much on
your substantive field or intended readership) you may want to report
that in different terms. For example, the times of year at which
"subjects" (whatever that means) reach a maximum (or a minimum) in a
fitted yearly cycle may make scientific or practical sense.
Nick
[email protected]
On 24 March 2014 11:34, Nilay Kumar <[email protected]> wrote:
> Dear Statalisters,
>
> I have a time series dataset that I'm using to perform a cosinor
> analysis. There are four subjects with 400 weekly observations with a
> seasonal pattern of variation. I used OLS regression to fit a
> sinusoidal wave to these variables using the cosine and sine functions
> of time as predictors.
> I want to know how I can calculate the phase difference between the
> different sine waves generated by the OLS regression for different
> variables. If someone can suggest a way to graphically represent the
> phase difference that would be very helpful. Thanks in advance for
> your time!
>
> Sincerely,
> Nilay
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/