euler_ridge | R Documentation |
Functions to perform density ridge estimation on the
polysphere \mathcal{S}^{d_1} \times \cdots \times \mathcal{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.
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 vector of size |
paths |
an array of size |
start_x |
a matrix of size |
iter |
a column vector of size |
conv |
a column vector of size |
d |
vector |
h |
bandwidth used for the kernel density estimator. |
error |
a column vector of size |
## 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")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.