show_ridge_pca {ridgetorus}R Documentation

Illustration of toroidal PCA via density ridges

Description

Shows the scores computation for PCA via density ridges on [-\pi, \pi)^2.

Usage

show_ridge_pca(
  fit,
  n_max = 500,
  projs = TRUE,
  projs_lines = TRUE,
  signs = TRUE,
  col_data = 1,
  col_projs = c(3, 4),
  main = "",
  N = 500,
  at2 = TRUE
)

Arguments

fit

the output of ridge_pca.

n_max

maximum number of data points to draw. These are sampled from the data provided. Defaults to 500.

projs

draw projections? Defaults to TRUE.

projs_lines

draw projection lines? Defaults to TRUE.

signs

plot the original data points with + and - facets depending on the signs of the second scores? Defaults to TRUE.

col_data

color(s) for the data points. Defaults to 1.

col_projs

a vector of size 2 giving the colors for the curve-projected data and the ridge curve, respectively. Defaults to c(3, 4).

main

caption of the plot. Empty by default.

N

number of discretization points for approximating curve lengths. Defaults to 5e2.

at2

do the atan2 fit instead of the sine fit (only using S_m)? Defaults to TRUE. at2 = FALSE is not recommended to use.

Value

Nothing, the functions are called to produce plots.

Examples


# Generate data
set.seed(987654321)
n <- 50
S1 <- rbind(c(1, -0.7), c(-0.7, 1))
S2 <- rbind(c(1, 0.5), c(0.5, 1))
x <- rbind(mvtnorm::rmvnorm(n, mean = c(0, pi / 2), sigma = S1),
           mvtnorm::rmvnorm(n, mean = c(pi, -pi / 2), sigma = S2))
x <- sdetorus::toPiInt(x)
col <- rainbow(2)[rep(1:2, each = n)]

# ridge_pca and its visualization
fit <- ridge_pca(x = x, at2 = FALSE)
show_ridge_pca(fit = fit, col_data = col, at2 = FALSE)
fit2 <- ridge_pca(x = x, at2 = TRUE)
show_ridge_pca(fit = fit2, col_data = col, at2 = TRUE)

[Package ridgetorus version 1.0.2 Index]