Skip to contents

Computes the association between a heading (angle) series and either a continuous linear covariate (x_type = "linear", default) or a second set of angles (x_type = "circular").

Usage

circ_cor(
  hd,
  x_col,
  angle_col = "heading",
  group_col = NULL,
  x_type = c("linear", "circular"),
  test = TRUE
)

Arguments

hd

Data frame containing the heading and covariate columns.

x_col

Name of the covariate column.

angle_col

Heading column in radians. Default "heading".

group_col

Column to group by. NULL uses all rows.

x_type

"linear" (default) or "circular".

test

Logical; include hypothesis test. Default TRUE.

Value

Tidy data frame with columns group_col (if supplied), r, n, type, and when test = TRUE also statistic, df, p_value.

Details

Circular-linear (T-linear association, Mardia and Jupp 2000): $$r^2 = (r_{cx}^2 + r_{cy}^2 - 2 r_{cx} r_{cy} r_{xy}) / (1 - r_{xy}^2)$$ where \(r_{cx}\), \(r_{cy}\), and \(r_{xy}\) are the Pearson correlations of \(x\) with \(\cos\theta\) and \(\sin\theta\), and of \(\cos\theta\) with \(\sin\theta\). \(r\) lies in \([0, 1]\); the test statistic \(n r^2\) is approximately chi-squared with 2 degrees of freedom under the null. Note: \(r\) is unsigned (association strength only, not direction).

Circular-circular (Fisher's \(\rho\), via cor.circular): \(r \in [-1, 1]\).