frechet {ridgetorus} | R Documentation |
Fréchet statistics on the torus
Description
Computes the Fréchet mean, variance, and standard deviation of
a sample on the d
-torus [-l, l)^d
, d\geq 1
, with
-l \equiv l
identified.
Usage
frechet_mean(x, l = pi, N = 500, draw_plot = FALSE)
frechet_ss(x, l = pi, N = 500, draw_plot = FALSE)
Arguments
x |
sample of angles on |
l |
half-period of the circular data. Can be a vector of length
|
N |
size of the grid in |
draw_plot |
draw a diagnostic plot showing the Fréchet loss function?
Defaults to |
Value
-
frechet_mean
: a list with the marginal Fréchet means (mu
), variances (var
), and standard deviations (sd
). -
frechet_ss
: a list with the Fréchet variances (var
) and the cumulative proportion of total variance explained (var_exp
).
Examples
## Circular data
# Sample from a wrapped normal
x <- sdetorus::toPiInt(rnorm(n = 5e2, mean = 2, sd = 1))
frechet_mean(x = x)
# Sample from a bimodal distribution
x <- sdetorus::toPiInt(rnorm(n = 5e2, mean = c(1, -2), sd = c(0.5, 0.75)))
frechet_mean(x = x)
# Periodic data in [-2, 2)
x <- sdetorus::toInt(rnorm(n = 5e2, mean = c(-2, 1), sd = 2:1),
a = -2, b = 2)
frechet_mean(x = x, l = 2)
## Toroidal data
# Sample from a multivariate wrapped normal
n <- 50
S <- rbind(c(2.5, -0.2, 0.5),
c(-0.2, 1.5, -0.5),
c(0.5, -0.5, 0.75))
x <- sdetorus::toPiInt(mvtnorm::rmvnorm(n, mean = c(0, 1.5, -2), sigma = S))
(f <- frechet_mean(x = x))
# Total Fréchet variance is sum of marginal variances
sum(torus_dist(x, y = f$mu, squared = TRUE)) / n
sum(f$var)
# Cumulative proportion of variances
frechet_ss(x)
[Package ridgetorus version 1.0.2 Index]