Application of Circular Regression

I am struggling to learn more about how to use the circular package, specifically using a circular-circular regression using lm.circular . I have run through the example that is provided in the package documentation but have found little information as to what that line represents. Does anyone have any information as to what the line represents, application of fit statistics such as r^2 or if the line has to be fitted as opposed to linear?

library(circular)

# Generate a data set of dependent circular variables.
x <- circular(runif(50, 0, 2*pi))
y <- atan2(0.15*cos(x) + 0.25*sin(x), 0.35*sin(x)) + 
  rvonmises(n=50, mu=circular(0), kappa=5)

# Fit a circular-circular regression model.
circ.lm <- lm.circular(y, x, order=1)

# Obtain a crude plot of the data and fitted regression line.
plot.default(x, y)

circ.lm$fitted[circ.lm$fitted>pi] <- circ.lm$fitted[circ.lm$fitted>pi] - 2*pi 

points.default(x[order(x)], circ.lm$fitted[order(x)], type='l')

The eventual goal is to be able to identify a relationship between various directional data (0-360 degrees), but have been unable to adapt the c-c regression line to my data yet (example of intended plot below). I would appreciate any insights!

image

This is where a close reading of the documentation is essential.

help(lm.circular)

will give you the function signature and, importantly a description of the results object.

In the example

library(circular)
#> 
#> Attaching package: 'circular'
#> The following objects are masked from 'package:stats':
#> 
#>     sd, var
x <- circular(runif(50, 0, 2*pi))
y <- atan2(0.15*cos(x) + 0.25*sin(x), 0.35*sin(x)) + 
  rvonmises(n=50, mu=circular(0), kappa=5)
circ.lm <- lm.circular(y, x, order=1)

# Fitted values

circ.lm$fitted
#> Circular Data: 
#> Type = angles 
#> Units = radians 
#> Template = none 
#> Modulo = asis 
#> Zero = 0 
#> Rotation = counter 
#>           1           2           3           4           5           6 
#> 3.584805191 5.036839325 3.827759844 1.860183750 1.012927134 0.623191891 
#>           7           8           9          10          11          12 
#> 0.684865489 2.173393246 1.463051394 5.831505475 1.034205699 5.112500596 
#>          13          14          15          16          17          18 
#> 4.246131160 3.750375687 2.443336747 3.573768858 1.044550019 0.966170053 
#>          19          20          21          22          23          24 
#> 0.006255199 0.716375074 5.111807016 3.671379396 1.690398526 5.716296738 
#>          25          26          27          28          29          30 
#> 4.883451500 5.010154295 4.687624648 4.196460592 2.531515232 3.701005477 
#>          31          32          33          34          35          36 
#> 0.867358506 0.692228271 1.445646671 5.242795991 5.073564066 3.408020213 
#>          37          38          39          40          41          42 
#> 5.921077493 5.675459227 6.249241839 2.061586508 4.062892956 0.333189224 
#>          43          44          45          46          47          48 
#> 4.413920236 1.301929594 3.643252066 5.071906724 0.128641440 2.200886117 
#>          49          50 
#> 4.520979456 4.885870701

# Residuals

circ.lm$residual
#> Circular Data: 
#> Type = angles 
#> Units = radians 
#> Template = none 
#> Modulo = asis 
#> Zero = 0 
#> Rotation = counter 
#>           1           2           3           4           5           6 
#> 0.264099077 0.045419128 0.007534907 5.650239152 5.831479349 0.886496312 
#>           7           8           9          10          11          12 
#> 6.218350599 0.473989862 0.589954179 0.222075881 5.623060335 1.027383327 
#>          13          14          15          16          17          18 
#> 0.145849820 0.106816333 5.515730408 6.250560505 0.536877341 5.812140644 
#>          19          20          21          22          23          24 
#> 0.405705429 5.541883729 6.221256118 0.364964105 5.362169950 0.512980044 
#>          25          26          27          28          29          30 
#> 5.979569932 6.123198428 5.955293469 0.249679836 0.437242471 0.073642262 
#>          31          32          33          34          35          36 
#> 6.214767619 5.243128299 0.107702241 0.580270656 5.577650810 0.581707762 
#>          37          38          39          40          41          42 
#> 0.449103551 5.920531055 5.752178725 5.780390855 0.430300811 5.951595177 
#>          43          44          45          46          47          48 
#> 0.052553097 0.322211203 0.081596574 0.268359964 6.188204993 1.176300684 
#>          49          50 
#> 5.807317576 5.727102545

# Coefficients

circ.lm$coefficients
#>                   [,1]       [,2]
#> (Intercept)  0.1289833 -0.1553619
#> cos.x       -0.1693289  0.6632196
#> sin.x        0.9156365  0.5102716

# p-values

circ.lm$p.values
#>           [,1]       [,2]
#> [1,] 0.8314844 0.02521169

Created on 2019-02-27 by the reprex package (v0.2.1)

You have everything you need (intercept and data to calculate slope).

plot.default is a base function that produces the points and has options to add lines.

Thank you for pointing out those coefficients, I will try playing around with those. Are the cosy and siny what you would use to find the slope? I am still curious as to how the fitted line they suggest is supposed work though, especially since the idea is to create a piece-wise polynomial.
Clarifying on the fit statistics, while looking through the summary of circ.lm , it also produces A.k. and kappa. Does you know what inferences can be made with A.k. (the mean of the cosines of the circular residuals)? And am I correct in assuming that a larger kappa (in this case $kappa 5.153668) suggests a better concentration and therefore a better regression fit? If so, how does this change if it is pre-defined like the data produced for example?

1 Like

The leading text seems to be Topics in Circular Statistics by S. Rao Jammalamadaka and A. SenGupta. Related titles can be found on Google Scholar

I have now exhausted my entire knowledge on the field. Thanks for raising the question. I may never have known otherwise. Bet the climate guys use it a lot.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.