Learn R Programming

cylcop (version 0.2.0)

cor_cyl: Estimate a Rank-Based Circular-Linear Correlation Coefficient

Description

The code is based on Mardia1976;textualcylcop, Solow1988;textualcylcop and Tu2015;textualcylcop. The function returns a numeric value between 0 and 1, not -1 and 1, positive and negative correlation cannot be discerned. Note also that the correlation coefficient is independent of the marginal distributions.

Usage

cor_cyl(theta, x)

Value

A numeric value between 0 and 1, the circular-linear correlation coefficient.

Arguments

theta

numeric vector of angles (measurements of a circular variable).

x

numeric vector of step lengths (measurements of a linear variable).

References

Mardia1976cylcop

Solow1988cylcop

Tu2015cylcop

Hodelmethodcylcop

See Also

mi_cyl(), fit_cylcop_cor().

Examples

Run this code
set.seed(123)

cop <- cyl_quadsec(0.1)

#draw samples and calculate the correlation coefficient
sample <- rcylcop(100, cop)
cor_cyl(theta = sample[,1], x = sample[,2])

#the correlation coefficient is independent of the marginal distribution.
sample <- traj_sim(100,
  cop,
  marginal_circ = list(name = "vonmises", coef  = list(0, 1)),
  marginal_lin = list(name = "weibull", coef = list(shape = 2))
)
cor_cyl(theta = sample$angle, x = sample$steplength)
cor_cyl(theta = sample$cop_u, x = sample$cop_v)

# Estimate correlation of samples drawn from circular-linear copulas with
# perfect correlation
cop <- cyl_rect_combine(copula::normalCopula(1))
sample <- rcylcop(100, cop)
cor_cyl(theta = sample[,1], x = sample[,2])

Run the code above in your browser using DataLab