The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
performs Bayesian wavelet analysis using individual non-local priors as described in Sanyal & Ferreira (2017) and non-local prior mixtures as described in Sanyal (2025).
You can install the development version of NLPwavelet like so:
install.packages("NLPwavelet")
# install.packages("devtools")
::install_github("nilotpalsanyal/NLPwavelet") devtools
BNLPWA is the main function of this package that performs Bayesian wavelet analysis using individual non-local priors as described in Sanyal & Ferreira (2017) and non-local prior mixtures as described in Sanyal (2025). It currently works with one-dimensional data. The usage is described below.
library(NLPwavelet)
#>
#> Welcome to NLPwavelet!
#>
#> Website: https://nilotpalsanyal.github.io/NLPwavelet/
#> Bug report: https://github.com/nilotpalsanyal/NLPwavelet/issues
# Using the well-known Doppler function to
# illustrate the use of the function BNLPWA
# set seed for reproducibility
set.seed(1)
# Define the doppler function
<- function(x) {
doppler sqrt(x * (1 - x)) * sin((2 * pi * 1.05) / (x + 0.05))
}
# Generate true values over a grid
<- 512 # Number of points
n <- seq(0, 1, length.out = n)
x <- doppler(x)
true_signal
# Add noise to generate data
<- 0.2 # Noise level
sigma <- true_signal + rnorm(n, mean = 0, sd = sigma)
y
# BNLPWA analysis based on MOM prior using logit specification
# for the mixture probabilities and polynomial decay
# specification for the scale parameter
<- BNLPWA(data=y, func=true_signal, r=1, wave.family=
fit_mom "DaubLeAsymm", filter.number=6, bc="periodic", method="mom",
mixprob_dist="logit", scale_dist="polynom")
plot(y,type="l",col="grey") # plot of data
lines(fit_mom$func.post.mean,col="blue") # plot of posterior
# smoothed estimates
$MSE.mean
fit_mom#> [1] 0.006592428
# BNLPWA analysis using non-local prior mixtures using generalized
# logit (Richard's) specification for the mixture probabilities and
# double exponential decay specification for the scale parameter
<- BNLPWA(data=y, func=true_signal, r=1, nu=1, wave.family=
fit_mixture "DaubLeAsymm", filter.number=6, bc="periodic", method="mixture",
mixprob_dist="genlogit", scale_dist="doubleexp")
plot(y,type="l",col="grey") # plot of data
lines(fit_mixture$func.post.mean,col="blue") # plot of posterior
# smoothed estimates
$MSE.mean
fit_mixture#> [1] 0.006335836
# Compare with other wavelet methods
library(wavethresh)
#> Loading required package: MASS
#> WaveThresh: R wavelet software, release 4.7.2, installed
#> Copyright Guy Nason and others 1993-2022
#> Note: nlevels has been renamed to nlevelsWT
<- wd(y, family="DaubLeAsymm", filter.number=6, bc="periodic") # Wavelet decomposition
wd
<- threshold(wd, policy="universal", type="hard")
wd_thresh_universal <- wr(wd_thresh_universal)
fit_universal <- mean((true_signal-fit_universal)^2)
MSE_universal
MSE_universal#> [1] 0.009054956
<- threshold(wd, policy="sure", type="soft")
wd_thresh_sure <- wr(wd_thresh_sure)
fit_sure <- mean((true_signal-fit_sure)^2)
MSE_sure
MSE_sure#> [1] 0.01758871
<- threshold(wd, policy="BayesThresh", type="hard")
wd_thresh_BayesThresh <- wr(wd_thresh_BayesThresh)
fit_BayesThresh <- mean((true_signal-fit_BayesThresh)^2)
MSE_BayesThresh
MSE_BayesThresh#> [1] 0.007527764
<- threshold(wd, policy="cv", type="hard")
wd_thresh_cv <- wr(wd_thresh_cv)
fit_cv <- mean((true_signal-fit_cv)^2)
MSE_cv
MSE_cv#> [1] 0.008710683
<- threshold(wd, policy="fdr", type="hard")
wd_thresh_fdr <- wr(wd_thresh_fdr)
fit_fdr <- mean((true_signal-fit_fdr)^2)
MSE_fdr
MSE_fdr#> [1] 0.007777847
# Compare with non-wavelet methods
# Kernel smoothing
<- ksmooth(x, y, kernel="normal", bandwidth=0.05)
fit_ksmooth <- mean((true_signal-fit_ksmooth$y)^2)
MSE_ksmooth
MSE_ksmooth#> [1] 0.01518292
# LOESS smoothing
<- loess(y ~ x, span=0.1) # Adjust span for more or less smoothing
fit_loess <- mean((true_signal-predict(fit_loess))^2)
MSE_loess
MSE_loess#> [1] 0.01059615
# Cubic spline smoothing
<- smooth.spline(x, y, spar=0.5) # Adjust spar for smoothness
spline_fit <- mean((true_signal-spline_fit$y)^2)
MSE_spline
MSE_spline#> [1] 0.01083473
Sanyal, Nilotpal, and Marco AR Ferreira. “Bayesian wavelet analysis using nonlocal priors with an application to FMRI analysis.” Sankhya B 79.2 (2017): 361-388. https://doi.org/10.1007/s13571-016-0129-3
Sanyal, Nilotpal. “Nonlocal prior mixture-based Bayesian wavelet regression.” arXiv preprint arXiv:2501.18134 (2025). https://doi.org/10.48550/arXiv.2501.18134
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.