| euler_ridge | R Documentation |
Functions to perform density ridge estimation on the polysphere
\mathbb{S}^{d_1} \times \cdots \times \mathbb{S}^{d_r} through the
Euler algorithm in standard, parallel, or block mode.
euler_ridge(
x,
X,
d,
h,
h_euler = as.numeric(c()),
weights = as.numeric(c()),
wrt_unif = FALSE,
normalized = TRUE,
norm_x = FALSE,
norm_X = FALSE,
kernel = 1L,
kernel_type = 1L,
k = 10,
N = 1000L,
eps = 1e-05,
keep_paths = FALSE,
proj_alt = TRUE,
fix_u1 = TRUE,
sparse = FALSE,
show_prog = TRUE,
show_prog_j = FALSE
)
parallel_euler_ridge(
x,
X,
d,
h,
h_euler,
N = 1000,
eps = 1e-05,
keep_paths = FALSE,
cores = 1,
...
)
block_euler_ridge(
x,
X,
d,
h,
h_euler,
ind_blocks,
N = 1000,
eps = 1e-05,
keep_paths = FALSE,
cores = 1,
...
)
x |
a matrix of size |
X |
a matrix of size |
d |
vector of size |
h |
vector of size |
h_euler |
vector of size |
weights |
weights for each observation. If provided, a vector of size
|
wrt_unif |
flag to return a density with respect to the uniform
measure. If |
normalized |
flag to compute the normalizing constant of the kernel and
include it in the kernel density estimator. Defaults to |
norm_x, norm_X |
ensure a normalization of the data? Defaults to
|
kernel |
kernel employed: |
kernel_type |
type of kernel employed: |
k |
softplus kernel parameter. Defaults to |
N |
maximum number of Euler iterations. Defaults to |
eps |
convergence tolerance. Defaults to |
keep_paths |
keep the Euler paths to the ridge? Defaults to
|
proj_alt |
alternative projection. Defaults to |
fix_u1 |
ensure the |
sparse |
use a sparse eigendecomposition of the Hessian? Defaults to
|
show_prog |
display a progress bar for |
show_prog_j |
display a progress bar for |
cores |
cores to use. Defaults to |
... |
further arguments passed to |
ind_blocks |
indexes of the blocks, a vector or length |
euler_ridge is the main function to perform density ridge
estimation through the Euler algorithm from the starting values x
to initiate the ridge path. The function euler_ridge_parallel
parallelizes on the starting values x. The function
euler_ridge_block runs the Euler algorithm marginally in blocks
of spheres, instead of jointly in the whole polysphere. This function
requires that all the dimensions are the same. Only the von Mises–Fisher
product kernel (kernel = 1, kernel_type = 1) is supported.
The three functions return a list with the following fields:
ridge_y |
a matrix of size |
lamb_norm_y |
a matrix of size |
log_dens_y |
a column matrix of size |
paths |
an array of size |
start_x |
a matrix of size |
iter |
a column matrix of size |
conv |
a column matrix of size |
d |
vector |
h |
bandwidth used for the kernel density estimator. |
error |
a column matrix of size |
García-Portugués, E. and Meilán-Vila, A. (2023). Hippocampus shape analysis via skeletal models and kernel smoothing. In Larriba, Y. (Ed.), Statistical Methods at the Forefront of Biomedical Advances, pp. 63–82. Springer, Cham. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/978-3-031-32729-2_4")}
clean_euler_ridge, index_ridge,
proj_grad_kde_polysph, grad_hess_kde_polysph.
if (requireNamespace("scatterplot3d", quietly = TRUE) &&
requireNamespace("viridis", quietly = TRUE)) {
## Test on S^2 with a small circle trend
# Sample
r <- 1
d <- 2
n <- 50
ind_dj <- comp_ind_dj(d = d)
set.seed(987204452)
X <- r_path_s2r(n = n, r = r, spiral = FALSE, Theta = cbind(c(1, 0, 0)),
sigma = 0.35)[, , 1]
col_X_alp <- viridis::viridis(n, alpha = 0.25)
col_X <- viridis::viridis(n)
# Euler
h_rid <- 0.5
h_eu <- h_rid^2
N <- 30
eps <- 1e-6
Y <- euler_ridge(x = X, X = X, d = d, h = h_rid, h_euler = h_eu,
N = N, eps = eps, keep_paths = TRUE)
Y
# Visualization
i <- N # Between 1 and N
sc3 <- scatterplot3d::scatterplot3d(Y$paths[, , 1], color = col_X_alp,
pch = 19, xlim = c(-1, 1),
ylim = c(-1, 1), zlim = c(-1, 1),
xlab = "x", ylab = "y", zlab = "z")
sc3$points3d(rbind(Y$paths[, , i]), col = col_X, pch = 16, cex = 0.75)
for (k in seq_len(nrow(Y$paths))) {
sc3$points3d(t(Y$paths[k, , ]), col = col_X_alp[k], type = "l")
}
}
## Parallel and block variants on (S^2)^4
set.seed(987204452)
r <- 4
d <- rep(2, r)
ind_dj <- comp_ind_dj(d = d)
n <- 30
X <- r_unif_polysph(n = n, d = d)
h_rid <- rep(0.7, r)
h_eu <- h_rid^2
# Parallel: same algorithm as euler_ridge but distributing starting points
Y_par <- parallel_euler_ridge(x = X[1:5, , drop = FALSE], X = X, d = d,
h = h_rid, h_euler = h_eu, N = 20, cores = 1)
# Block: marginal Euler over groups of spheres (all d's must be equal)
Y_block <- block_euler_ridge(x = X[1:5, , drop = FALSE], X = X, d = d,
h = h_rid, h_euler = h_eu,
ind_blocks = c(1, 1, 2, 2), N = 20)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.