Learn R Programming

circhelp

circhelp is a small helper package for circular data analyses in R, particularly useful for cognitive studies on orientation, motion direction, and other circular features. The package contains functions for descriptive statistics for circular data (computing means, SD, and skewness), angular differences, and correlation. It also includes a function to correct for cardinal biases in the human estimates of circular features (e.g., orientation).

Installation

You can install the current version from GitHub with:

# install.packages("devtools")
devtools::install_github("achetverikov/circhelp")

Usage

Most functions are self-explanatory.

library(circhelp)
#> Loading required package: data.table
#> Loading required package: ggplot2
library(mgcv)
#> Loading required package: nlme
#> This is mgcv 1.9-1. For overview type 'help("mgcv-package")'.
# compute a set of descriptive statistics
x <- rnorm(500)
circ_descr(x)
#> $mu
#> [1] 0.07084994
#> 
#> $sigma
#> [1] 0.9691056
#> 
#> $skew_pewsey
#> [1] 0.0118935
#> 
#> $skew_fischer
#> [1] -0.04671673
#> 
#> $rho
#> [1] 0.6252631
#> 
#> $skew_rel_to_zero
#> [1] 0.03426532

# compute difference in orientations
a <- 5
b <- 170
angle_diff_180(a, b)
#> [1] 15

# compute difference in 360° space (e.g., motion directions)
angle_diff_360(a, b)
#> [1] -165

# compute correlation between angles
data <- rmvn(10000, c(0, 0), V = matrix(c(1, 0.5, 0.5, 1), ncol = 2))
circ_corr(data[, 1], data[, 2])
#> [1] 0.4392524

The only (somewhat) complicated function is remove_cardinal_biases, see the help files and the vignette for an example use case.

Copy Link

Version

Install

install.packages('circhelp')

Monthly Downloads

235

Version

1.1

License

CC0

Issues

Pull Requests

Stars

Forks

Maintainer

Andrey Chetverikov

Last Published

July 4th, 2024

Functions in circhelp (1.1)

remove_cardinal_biases

Remove cardinal biases
angle_diff_rad

Differences between angles in different circular spaces
circ_loess

An implementation of circular-linear locally-weighted regression (LOESS)
circ_lin_corr

Circular-linear correlation
circ_corr

Circular correlation coefficient
circ_mean_rad

Circular mean
circ_descr

A set of descriptive statistics for circular data
circ_sd_rad

Circular standard deviation
Pascucci_et_al_2019_data

Data from an orientation estimation task
Bae_Luck_2018_data

Data from a motion estimation task
vm_kappa_to_circ_sd

Conversion between the circular SD and kappa of von Mises
pad_circ

Pad circular data on both ends
weighted_sem

Weighted standard error of the mean (SEM_w)
remove_cardinal_biases_discrete

Remove cardinal biases for data with orientation (color, motion, ...) set in discrete steps
correct_angle_rad

Get angle value in [-pi, pi] space
weighted_circ_mean

Weighted circular parameters
get_boundary_preds

Get polynomial predictions for values at the boundaries
make_plots_of_biases

Plots biases using the data from remove_cardinal_biases
predict.circ_loess

Compute predictions for circular LOESS
circhelp-package

circhelp: Circular Analyses Helper Functions