# Kernels in the projected-ecdf test statistics
k <- 0:10
coefs <- list()
(coefs$PCvM <- t(sapply(2:5, function(p)
Gegen_coefs_Pn(k = k, p = p, type = "PCvM"))))
(coefs$PAD <- t(sapply(2:5, function(p)
Gegen_coefs_Pn(k = k, p = p, type = "PAD"))))
(coefs$PRt <- t(sapply(2:5, function(p)
Gegen_coefs_Pn(k = k, p = p, type = "PRt"))))
# Gegenbauer expansion
th <- seq(0, pi, length.out = 501)[-501]
old_par <- par(mfrow = c(3, 4))
for (type in c("PCvM", "PAD", "PRt")) {
for (p in 2:5) {
plot(th, psi_Pn(theta = th, q = p - 1, type = type), type = "l",
main = paste0(type, ", p = ", p), xlab = expression(theta),
ylab = expression(psi(theta)), axes = FALSE, ylim = c(-1.5, 1))
axis(1, at = c(0, pi / 4, pi / 2, 3 * pi / 4, pi),
labels = expression(0, pi / 4, pi / 2, 3 * pi / 4, pi))
axis(2); box()
lines(th, Gegen_series(theta = th, coefs = coefs[[type]][p - 1, ],
k = k, p = p), col = 2)
}
}
par(old_par)
# Analytical coefficients vs. numerical integration
test_coef <- function(type, p, k = 0:20) {
plot(k, log1p(abs(Gegen_coefs_Pn(k = k, p = p, type = type))),
ylab = "Coefficients", main = paste0(type, ", p = ", p))
points(k, log1p(abs(Gegen_coefs(k = k, p = p, psi = psi_Pn, type = type,
q = p - 1))), col = 2)
legend("topright", legend = c("log(1 + Gegen_coefs_Pn))",
"log(1 + Gegen_coefs(psi_Pn))"),
lwd = 2, col = 1:2)
}
# PCvM statistic
old_par <- par(mfrow = c(2, 2))
for (p in 2:5) test_coef(type = "PCvM", p = p)
par(old_par)
# PAD statistic
old_par <- par(mfrow = c(2, 2))
for (p in 2:5) test_coef(type = "PAD", p = p)
par(old_par)
# PRt statistic
old_par <- par(mfrow = c(2, 2))
for (p in 2:5) test_coef(type = "PRt", p = p)
par(old_par)
# akx
akx(x = seq(-1, 1, l = 5), k = 1:4, p = 2)
akx(x = 0, k = 1:4, p = 3)
# PRt alternative to uniformity
z <- seq(-1, 1, l = 1e3)
p <- c(2:5, 10, 15, 17)
col <- viridisLite::viridis(length(p))
plot(z, f_locdev_Pn(p = p[1], type = "PRt")(z), type = "s",
col = col[1], ylim = c(0, 0.6), ylab = expression(f[Rt](z)))
for (k in 2:length(p)) {
lines(z, f_locdev_Pn(p = p[k], type = "PRt")(z), type = "s", col = col[k])
}
legend("topleft", legend = paste("p =", p), col = col, lwd = 2)
Run the code above in your browser using DataLab