Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
linear regression for circular-linear data

Subject: linear regression for circular-linear data

From: pierre lenck-santini

Date: 1 Nov, 2006 13:50:42

Message: 1 of 11

Hi,
I am having a trouble :
let's say you have circular-linear data (distance of a measure vs
phase of a signal).
How do you establish the relationship between the two variables? I
already computed the circular-linear correlation coefficient (based
on Mardia's work). But I would like to compute the slope of the
regression line.
There must be an algorhythm out there
any one knows?
I don't use R but they have this function.

Subject: linear regression for circular-linear data

From: Scott Seidman

Date: 1 Nov, 2006 19:38:03

Message: 2 of 11

"pierre Lenck-Santini" <pepe_lenck@yahoo.fr> wrote in news:ef45058.-1
@webcrossing.raydaftYaTP:

> Hi,
> I am having a trouble :
> let's say you have circular-linear data (distance of a measure vs
> phase of a signal).
> How do you establish the relationship between the two variables? I
> already computed the circular-linear correlation coefficient (based
> on Mardia's work). But I would like to compute the slope of the
> regression line.
> There must be an algorhythm out there
> any one knows?
> I don't use R but they have this function.
>

Title:
Statistical Analysis of Circular Data
ISBN:
0521568900
Publisher:
Cambridge University Press
Author(s):
Nicholas I. Fisher
Format:
Paperback
Publication Date:
Jan 1, 1996
Subject:
Mathematics
Dimensions:
6.81 x 9.72 x .71 in
Pages:
295

Chapter 6 will have everything you want


--
Scott
Reverse name to reply

Subject: linear regression for circular-linear data

From: ellieandrogerxyzzy@mindspring.com.invalid (Roger Stafford)

Date: 1 Nov, 2006 20:26:09

Message: 3 of 11

In article <ef45058.-1@webcrossing.raydaftYaTP>, "pierre Lenck-Santini"
<pepe_lenck@yahoo.fr> wrote:

> Hi,
> I am having a trouble :
> let's say you have circular-linear data (distance of a measure vs
> phase of a signal).
> How do you establish the relationship between the two variables? I
> already computed the circular-linear correlation coefficient (based
> on Mardia's work). But I would like to compute the slope of the
> regression line.
> There must be an algorhythm out there
> any one knows?
> I don't use R but they have this function.
------------------------
  It seems to me that, instead of looking for a line of regression, you
should be looking for a plane of regression; that is, a best-fitting plane
for linear data against data restricted to vectors on the unit circle. In
other words, if t is a vector of angular data, 0 to 2*pi, and s is a
corresponding vector of linear data, you would want to choose constants a,
b, and c so as to minimize the quantity

 sum((a*cos(t)+b*sin(t)+c-s).^2).

That leads to a standard linear least squares problem using the arrays

 A = [mean(cos(t).^2),mean(cos(t).*sin(t)),mean(cos(t)); ...
      mean(cos(t).*sin(t)),mean(sin(t).^2),mean(sin(t));
      mean(cos(t)),mean(sin(t),1];

 u = [mean(cos(t).*s);mean(sin(t).*s);mean(s)];

where you wish to solve A*x = u. Its solution is given by

 x = A\u;

The three coefficients will be a = x(1), b = x(2), and c = x(3). Your
best-fitting plane to the s and t data would then have the equation

 s2 = a*cos(t) + b*sin(t) + c

  Of course, this plane will have a direction of maximum gradient
determined by the coefficients a and b, and a line in the plane along that
direction could be considered a line of regression. However, it requires
some approach such as the above to determine that best direction.

Roger Stafford

Subject: linear regression for circular-linear data

From: pierre lenck-santini

Date: 1 Nov, 2006 16:26:58

Message: 4 of 11

Scott Seidman wrote:
>
>
> "pierre Lenck-Santini" <pepe_lenck@yahoo.fr> wrote in
> news:ef45058.-1
> @webcrossing.raydaftYaTP:
 
> Title:
> Statistical Analysis of Circular Data
> ISBN:
> 0521568900
> Publisher:
> Cambridge University Press
> Author(s):
> Nicholas I. Fisher
> Format:
> Paperback
> Publication Date:
> Jan 1, 1996
> Subject:
> Mathematics
> Dimensions:
> 6.81 x 9.72 x .71 in
> Pages:
> 295
>
> Chapter 6 will have everything you want
>
>
> --
> Scott
> Reverse name to reply
>
That's my bedside book right now but I am a little lost : I need to
know if I can predict my phase based on the distance I measure.
two ways are open to me : either I perform a c-linear association
type analysis (p145). then, in case of a significant association, "
the associated regression model can now be fitted by standard
methods" what does it mean?
I can't use the basic phi = ax+b stuff with cov(x,phi)/var(x) being
the slope, it's circular....

or, based on what is said on the book, I need to perform a
circular-circular correlation (T-linear association)on phase vs
2atan(distance) cf, p 161.
the rho value I get doing fisher is really different from the
linear-circular C-linear association r value I get from p145 (this
one looks appropriate). why is it different? Am I right to use this
method rather than the other? it's too subtile for me.
Then, the regression is pretty hard to implement (I am blond a little
:) I mean I am a neuroscientist, not a statistician).

but thanks, the book is great
>
> Title:
> Statistical Analysis of Circular Data
> ISBN:
> 0521568900
> Publisher:
> Cambridge University Press
> Author(s):
> Nicholas I. Fisher
> Format:
> Paperback
> Publication Date:
> Jan 1, 1996
> Subject:
> Mathematics
> Dimensions:
> 6.81 x 9.72 x .71 in
> Pages:
> 295
>
> Chapter 6 will have everything you want
>
>
> --
> Scott
> Reverse name to reply
>

Subject: linear regression for circular-linear data

From: ellieandrogerxyzzy@mindspring.com.invalid (Roger Stafford)

Date: 2 Nov, 2006 10:00:35

Message: 5 of 11

In article
<ellieandrogerxyzzy-0111061226040001@dialup-4.232.57.133.dial1.losangeles1.level3.net>,
ellieandrogerxyzzy@mindspring.com.invalid (Roger Stafford) wrote:

> In article <ef45058.-1@webcrossing.raydaftYaTP>, "pierre Lenck-Santini"
> <pepe_lenck@yahoo.fr> wrote:
>
> > Hi,
> > I am having a trouble :
> > let's say you have circular-linear data (distance of a measure vs
> > phase of a signal).
> > How do you establish the relationship between the two variables? I
> > already computed the circular-linear correlation coefficient (based
> > on Mardia's work). But I would like to compute the slope of the
> > regression line.
> > There must be an algorhythm out there
> > any one knows?
> > I don't use R but they have this function.
> ------------------------
> .....
> A = [mean(cos(t).^2),mean(cos(t).*sin(t)),mean(cos(t)); ...
> mean(cos(t).*sin(t)),mean(sin(t).^2),mean(sin(t));
> mean(cos(t)),mean(sin(t),1];
>
> u = [mean(cos(t).*s);mean(sin(t).*s);mean(s)];
>
> where you wish to solve A*x = u. Its solution is given by
>
> x = A\u;
> .....
-----------------
  Pierre, it would have been better if I had said the following in solving
your (multiple linear regression) least squares problem.

  Let the angular and linear data, respectively t and s, be given as
column vectors. Then solve the least squares problem with:

 x = [cos(t),sin(t),ones(size(t))]\s;

You should get the same answer as before, but this makes better use of the
matlab backslash operator's abilities. Then, as before, a = x(1), b =
x(2), and c = x(3) will provide the least squares sense best fitting plane
to your data.

  If you define t0 = atan2(b,a) and r = sqrt(a^2+b^2), the regression
takes the form

 s2 = a*cos(t) + b*sin(t) + c = r*cos(t-t0) + c

and the highest value of predicted s2 will therefore lie in the t0 direction.

Roger Stafford

Subject: linear regression for circular-linear data

From: pierre lenck-santini

Date: 2 Nov, 2006 12:02:13

Message: 6 of 11

Thanks!
this looks like what is said in the book but more detailed!
then I can understand it!
now, do you think, as they say that the direction of the relationship
is really important. I mean, it seems more that x (the distance) is
the independant variable and phi (phase) is what I measure. normally,
the corerlation coefficient is the same if I flip my axes no?
my slope should be what... then?

Roger Stafford wrote:
>
>
> In article
>
<ellieandrogerxyzzy-0111061226040001@dialup-4.232.57.133.dial1.losa
n
> geles1.level3.net>,
> ellieandrogerxyzzy@mindspring.com.invalid (Roger Stafford) wrote:
>
>> In article <ef45058.-1@webcrossing.raydaftYaTP>, "pierre
> Lenck-Santini"
>> <pepe_lenck@yahoo.fr> wrote:
>>
>> > Hi,
>> > I am having a trouble :
>> > let's say you have circular-linear data (distance of a
measure
> vs
>> > phase of a signal).
>> > How do you establish the relationship between the two
> variables? I
>> > already computed the circular-linear correlation
coefficient
> (based
>> > on Mardia's work). But I would like to compute the slope
of the
>> > regression line.
>> > There must be an algorhythm out there
>> > any one knows?
>> > I don't use R but they have this function.
>> ------------------------
>> .....
>> A = [mean(cos(t).^2),mean(cos(t).*sin(t)),mean(cos(t)); ...
>> mean(cos(t).*sin(t)),mean(sin(t).^2),mean(sin(t));
>> mean(cos(t)),mean(sin(t),1];
>>
>> u = [mean(cos(t).*s);mean(sin(t).*s);mean(s)];
>>
>> where you wish to solve A*x = u. Its solution is given by
>>
>> x = A\u;
>> .....
> -----------------
> Pierre, it would have been better if I had said the following in
> solving
> your (multiple linear regression) least squares problem.
>
> Let the angular and linear data, respectively t and s, be given
> as
> column vectors. Then solve the least squares problem with:
>
> x = [cos(t),sin(t),ones(size(t))]\s;
>
> You should get the same answer as before, but this makes better use
> of the
> matlab backslash operator's abilities. Then, as before, a = x(1),
> b =
> x(2), and c = x(3) will provide the least squares sense best
> fitting plane
> to your data.
>
> If you define t0 = atan2(b,a) and r = sqrt(a^2+b^2), the
> regression
> takes the form
>
> s2 = a*cos(t) + b*sin(t) + c = r*cos(t-t0) + c
>
> and the highest value of predicted s2 will therefore lie in the t0
> direction.
>
> Roger Stafford
>

Subject: linear regression for circular-linear data

From: ellieandrogerxyzzy@mindspring.com.invalid (Roger Stafford)

Date: 2 Nov, 2006 20:02:05

Message: 7 of 11

In article <ef45058.4@webcrossing.raydaftYaTP>, "pierre Lenck-Santini"
<pepe_lenck@yahoo.fr> wrote:

> Thanks!
> this looks like what is said in the book but more detailed!
> then I can understand it!
> now, do you think, as they say that the direction of the relationship
> is really important. I mean, it seems more that x (the distance) is
> the independant variable and phi (phase) is what I measure. normally,
> the corerlation coefficient is the same if I flip my axes no?
> my slope should be what... then?
---------------------
  That is not how it looks to me, Pierre. Your distance measure, x, (I
called it s2) should be the dependent variable and the angle phi (I called
it t) the independent one. Consider the case when a and b in the best
fitting plane happen to both be zero. Then there is no way you could
consider phi as a function of x when x remains a constant in this best
fit.

  As to the importance of the direction I called phi = t0, it determines
the points where your x comes to a maximum and minimum, so I would suppose
that is important in understanding the relationship involved. This would
especially be true if the quantity r = sqrt(a^2+b^2) is large. On the
other hand, if r is small, all phi directions are nearly the same for x.

Roger Stafford

Subject: linear regression for circular-linear data

From: Greg Heath

Date: 3 Nov, 2006 02:21:30

Message: 8 of 11


pierre Lenck-Santini wrote:
> Hi,
> I am having a trouble :
> let's say you have circular-linear data (distance of a measure vs
> phase of a signal).
> How do you establish the relationship between the two variables? I
> already computed the circular-linear correlation coefficient (based
> on Mardia's work). But I would like to compute the slope of the
> regression line.
> There must be an algorhythm out there
> any one knows?
> I don't use R but they have this function.

In the case of reflections from a stationary radar target at range R,
the transmitted and received signals vary like cos(2*pi*f*(t - t0))
and cos(2*pi*f*(t - t0- 2*R/c)), respectively, where f is the
radar frequency, t is time, t0 a reference time and c the speed of
light.

Typically, R is measured from the receive and transmit time difference

R = c*(Trec -Ttrans) + error1

where the error is too large for precision work. The error can be
reduced by orders of magnitude by using the receive and transmit
signal phase difference and resolving the multiple of 2*pi phase
ambiguity.

This scenario is called "Phase-Derived-Range" and is not a
trivial task.

Your scenario appears to be "Range-Derived-Phase". Is this
correct? If so, what is the application?

Hope this helps.

Greg

Subject: linear regression for circular-linear data

From: Tim howe

Date: 5 Aug, 2009 13:14:02

Message: 9 of 11

I gather that the original poster is asking how to do a regression where phase is the dependent and position is the independent variable. Given that the poster is a neuroscientist, i would imagine it is to do with the firing phase, with respect to oscillations in the local field potential, of action potentials, possibly correlated to a behaving animal's position. Performing a regression on this kind of relationship is a problem I'm struggling to solve as well.

Roger, would I be correct in assuming that your solution would need to be modified were x to be the independent variable and phi the dependent? If so can you give me any hints as to what I need to be doing?

Thanks

tim

Ps. for clarity, the data set is a series of positions (of an animal moving on a one-dimensional track) , and a corresponding set of phases (of the action potential fired at this position with respect to an EEG rhythm). Each element in the data set represents a single action potential. Clearly there is no meaningful way in which the animal's position can be said to be 'caused' by the phase of the action potential, so phase must be the dependent variable.


"Greg Heath" <heath@alumni.brown.edu> wrote in message <1162549290.907501.141460@k70g2000cwa.googlegroups.com>...
>
> pierre Lenck-Santini wrote:
> > Hi,
> > I am having a trouble :
> > let's say you have circular-linear data (distance of a measure vs
> > phase of a signal).
> > How do you establish the relationship between the two variables? I
> > already computed the circular-linear correlation coefficient (based
> > on Mardia's work). But I would like to compute the slope of the
> > regression line.
> > There must be an algorhythm out there
> > any one knows?
> > I don't use R but they have this function.
>
> In the case of reflections from a stationary radar target at range R,
> the transmitted and received signals vary like cos(2*pi*f*(t - t0))
> and cos(2*pi*f*(t - t0- 2*R/c)), respectively, where f is the
> radar frequency, t is time, t0 a reference time and c the speed of
> light.
>
> Typically, R is measured from the receive and transmit time difference
>
> R = c*(Trec -Ttrans) + error1
>
> where the error is too large for precision work. The error can be
> reduced by orders of magnitude by using the receive and transmit
> signal phase difference and resolving the multiple of 2*pi phase
> ambiguity.
>
> This scenario is called "Phase-Derived-Range" and is not a
> trivial task.
>
> Your scenario appears to be "Range-Derived-Phase". Is this
> correct? If so, what is the application?
>
> Hope this helps.
>
> Greg
>

Subject: linear regression for circular-linear data

From: Cato

Date: 18 Nov, 2009 23:14:03

Message: 10 of 11

Hello,

I am trying to use the regress function in matlab to obtain residuals (i.e. rx) to use in a partial correlation coefficient. The thing is that the two parameters I am correlation are circular data (angle 0 to 360). It seems as if the regress function just gives residuals of linear data...is there a function to find residuals for circular data?

Thank you very much!

ellieandrogerxyzzy@mindspring.com.invalid (Roger Stafford) wrote in message <ellieandrogerxyzzy-0211061202060001@dialup-4.232.0.61.dial1.losangeles1.level3.net>...
> In article <ef45058.4@webcrossing.raydaftYaTP>, "pierre Lenck-Santini"
> <pepe_lenck@yahoo.fr> wrote:
>
> > Thanks!
> > this looks like what is said in the book but more detailed!
> > then I can understand it!
> > now, do you think, as they say that the direction of the relationship
> > is really important. I mean, it seems more that x (the distance) is
> > the independant variable and phi (phase) is what I measure. normally,
> > the corerlation coefficient is the same if I flip my axes no?
> > my slope should be what... then?
> ---------------------
> That is not how it looks to me, Pierre. Your distance measure, x, (I
> called it s2) should be the dependent variable and the angle phi (I called
> it t) the independent one. Consider the case when a and b in the best
> fitting plane happen to both be zero. Then there is no way you could
> consider phi as a function of x when x remains a constant in this best
> fit.
>
> As to the importance of the direction I called phi = t0, it determines
> the points where your x comes to a maximum and minimum, so I would suppose
> that is important in understanding the relationship involved. This would
> especially be true if the quantity r = sqrt(a^2+b^2) is large. On the
> other hand, if r is small, all phi directions are nearly the same for x.
>
> Roger Stafford

Subject: linear regression for circular-linear data

From: Cato

Date: 18 Nov, 2009 23:14:03

Message: 11 of 11

Hello,

I am trying to use the regress function in matlab to obtain residuals (i.e. rx) to use in a partial correlation coefficient. The thing is that the two parameters I am correlation are circular data (angle 0 to 360). It seems as if the regress function just gives residuals of linear data...is there a function to find residuals for circular data?

Thank you very much!

ellieandrogerxyzzy@mindspring.com.invalid (Roger Stafford) wrote in message <ellieandrogerxyzzy-0211061202060001@dialup-4.232.0.61.dial1.losangeles1.level3.net>...
> In article <ef45058.4@webcrossing.raydaftYaTP>, "pierre Lenck-Santini"
> <pepe_lenck@yahoo.fr> wrote:
>
> > Thanks!
> > this looks like what is said in the book but more detailed!
> > then I can understand it!
> > now, do you think, as they say that the direction of the relationship
> > is really important. I mean, it seems more that x (the distance) is
> > the independant variable and phi (phase) is what I measure. normally,
> > the corerlation coefficient is the same if I flip my axes no?
> > my slope should be what... then?
> ---------------------
> That is not how it looks to me, Pierre. Your distance measure, x, (I
> called it s2) should be the dependent variable and the angle phi (I called
> it t) the independent one. Consider the case when a and b in the best
> fitting plane happen to both be zero. Then there is no way you could
> consider phi as a function of x when x remains a constant in this best
> fit.
>
> As to the importance of the direction I called phi = t0, it determines
> the points where your x comes to a maximum and minimum, so I would suppose
> that is important in understanding the relationship involved. This would
> especially be true if the quantity r = sqrt(a^2+b^2) is large. On the
> other hand, if r is small, all phi directions are nearly the same for x.
>
> Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us