set.sigma {BBEST} | R Documentation |
Set the experimental uncertainty
Description
This function either sets the pointwise experimental uncertainty or estimates it using aws
library.
Usage
set.sigma(data, sigma=NA, x.bkg.only=NA, n.regions=10, hmax=250, sigma2=c(0.1))
Arguments
data |
an object of type |
sigma |
numeric vector which, if not |
x.bkg.only |
if parameter |
n.regions |
if both parameters |
hmax |
specifies the maximal bandwidth |
sigma2 |
specifies the estimation of the signal's variance |
Details
We assume the experimental uncertainty to have a Gaussian distribution with x-dependent amplitude. Splitting the grid into n.regions
segments and estimating Gaussian standard deviations over each of these segments allows us to approximate the true distribution.
The function uses aws
package that uses a Propagation-Separation Approach for signal smoothing. The use of sigma2
argument allows to obtain a smoother or rougher result.
Value
An object of type data
. Elements
sigma |
numeric vector containing the estimated noise level. |
smoothed |
if both parameters |
are replaced with their new values.
References
Polzehl J, Papafitsoros K, Tabelow K (2020). Patch-Wise Adaptive Weights Smoothing in R. Journal of Statistical Software, 95(6), 1-27. Joerg Polzehl, Felix Anker (2020): aws: Adaptive Weights Smoothing. Version 2.5. https://CRAN.R-project.org/package=aws.
Examples
## Not run:
# Setting x and y
x <- seq(.7, 30, 0.01)
y <- sin(x)
# Adding x-dependent noise
y <- y + rnorm(sd=0.05+x/240, n=length(x))
# estimating noise
dat <- list(x=x, y=y)
dat <- set.sigma(dat, n.regions=1, sigma2 = 0.005)
# use
# dat <- set.sigma(dat, n.regions=5)
# to see the difference
# Plotting results: noisy function and a
# smoothed estimate +/- 2 standard deviations
plot(x, y, t="l")
lines(dat$x, dat$smoothed, col=3, lwd=2)
lines(dat$x, dat$smoothed+2*dat$sigma, col=2)
lines(dat$x, dat$smoothed-2*dat$sigma, col=2)
abline(v=seq(min(x), max(x),length=5), col=4)
## End(Not run)