Last data update: 2014.03.03

R: Set the experimental uncertainty
set.sigmaR Documentation

Set the experimental uncertainty

Description

This function either sets the pointwise experimental uncertainty or estimates it using wmtsa library.

Usage

set.sigma(data, sigma=NA, x.bkg.only=NA, n.regions=10, thresh.scale=1)

Arguments

data

an object of type data. See set.data for details.

sigma

numeric vector which, if not NA, determines the pointwise experimental uncertainty.

x.bkg.only

if parameter sigma is NA, determines the peak-free region used to estimate the noise.

n.regions

if both parameters sigma and x.bkg.only are NA, the grid is split into n.regions equal regions. The noise is then estimated for each of these regions. See details

thresh.scale

numeric vector or scalar which is used to amplify or attenuate the threshold values for a wavelet shrinkage.

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 wavShrink package that performs a decimated discrete wavelet transform for signal smoothing. The use of thresh.scale argument signifies a departure from a model driven estimate of the thresholds and can be used to tweak the levels 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 sigma and x.bkg.only are NA contains a smoothed estimate of the regression function.

are replaced with their new values.

References

Percival, D. B. and Walden, A. T. (2000): Wavelet Methods for Time Series Analysis, Cambridge University Press.

Percival, D. B. (2013): wmtsa: Wavelet Methods for Time Series Analysis Version 2.0-0. http://CRAN.R-project.org/package=wmtsa.

Examples

# 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)
# 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)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(BBEST)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/BBEST/set.sigma.Rd_%03d_medium.png", width=480, height=480)
> ### Name: set.sigma
> ### Title: Set the experimental uncertainty
> ### Aliases: set.sigma
> ### Keywords: set data
> 
> ### ** Examples
> 
> # 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)

 step  1  of  1 

> # 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)
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>