kre_polysph: Local polynomial estimator for polyspherical-on-scalar...

View source: R/kre.R

kre_polysphR Documentation

Local polynomial estimator for polyspherical-on-scalar regression

Description

Computes a local constant (Nadaraya–Watson) or local linear estimator with polyspherical response and scalar predictor.

Usage

kre_polysph(x, X, Y, d, h, p = 0)

Arguments

x

a vector of size nx with the evaluation points.

X

a vector of size n with the predictor sample.

Y

a matrix of size c(n, sum(d) + r) with the response sample on the polysphere.

d

vector of size r with dimensions.

h

a positive scalar giving the bandwidth.

p

degree of local fit, either 0 or 1. Defaults to 0.

Value

A vector of size nx with the estimated regression curve evaluated at x.

Examples

x_grid <- seq(-0.25, 1.25, l = 200)
n <- 50
X <- seq(0, 1, l = n)
Y <- r_path_s2r(n = n, r = 1, sigma = 0.1, spiral = TRUE)[, , 1]
h0 <- bw_cv_kre_polysph(X = X, Y = Y, d = 2, p = 0, plot_cv = FALSE)$h_1se
sc3 <- scatterplot3d::scatterplot3d(Y, pch = 16, xlim = c(-1, 1),
                                    ylim = c(-1, 1), zlim = c(-1, 1),
                                    xlab = "", ylab = "", zlab = "")
sc3$points3d(kre_polysph(x = x_grid, X = X, Y = Y, d = 2, h = h0, p = 0),
             pch = 16, type = "l", col = 2, lwd = 2)
sc3$points3d(kre_polysph(x = x_grid, X = X, Y = Y, d = 2, h = h0, p = 1),
             pch = 16, type = "l", col = 3, lwd = 2)

polykde documentation built on April 16, 2025, 1:11 a.m.