function(data = 0, alpha = 0.5, beta = 1., filter.number = 8, family = "DaubLeAsymm", bc = "periodic", dev = var, j0 = 3., plotfn = T, retvalue = T, n = 128, type = "data", rsnr = 3)
data
or a value of type
other than
"data"
must be supplied.
data
type="data"
, then data
should be a
vector of data. The length of the vector should be a power of two not
greater than 1024.
type
type="data"
, in which case a vector of data
should be supplied, or type
should specify a standard
test function and wave.band
will generate a test data set
via a call to test.data
.
Permissible values for type
are "blocks",
"bumps", "doppler", "heavi", or "ppoly"; see the documentation for test.data
for more details.
alpha, beta
alpha
and beta
take
positive values; see Abramovich,
Sapatinas, & Silverman (1998) or Chipman & Wolfson (1999) for more
details on selecting alpha
and beta
.
filter.number
family
bc
bc="periodic"
the
default, then the function you decompose is assumed to be
periodic on it's interval of definition. Other boundary
options exist, but are currently unsupported for this function.
dev
var()
function. A popular, useful
and robust alternative is the madmad
function.
j0
plotfn
plotfn=T
, wave.band
draws the noisy
data, the BayesThresh function estimate,
and pointwise 99 percent credible intervals for the regression
function. If the value of type
is not
"data"
, then the true function will also be plotted.
retvalue
retvalue=T
, then a lengthy list of results will
be returned. Note that if both plotfn
and
retvalue
are set to F
, then
wave.band
will return no results whatsoever.
n
type
is not "data"
, then a data vector
of length n
will be generated; note that n
should be a power of two not greater than 1024.
rsnr
type
is not "data"
, then the data
vector generated will have root signal-to-noise ratio as specified by
rsnr
.
retvalue=F
, the value returned by
wave.band
is NULL
. Otherwise,
wave.band
returns a list with the following components:
data
cumulants
Kr.wd
bands
param
wave.band
.
plotfn=T
, results are plotted on the current graphics
device.
The cumulants of these posteriors are computed and stored in the wd
objects returned by wave.band
as Kr.wd
.
These are summed to give the posterior cumulants of the regression
curve, which are used to fit a Johnson distribution (Johnson, 1949), using the algorithm
of Hill, Hill, & Holder (1976).
Percentage points of these distributions are computed by the algorithm
of Hill (1976) and give the credible
intervals themselves.
Code to implement the algorithms by Hill
(1976) and Hill, Hill, & Holder
(1976) were obtained from the StatLib
archive.
# # First, look at the piecewise polynomial example. # # This plot and the plots for the smooth example below show # the data as points, the BayesThresh estimate (thick line), # pointwise 99 percent credible intervals (thin lines), and # the true function (dotted thin line). # ppoly.wb <- wave.band(type = "ppoly", n = 1024, rsnr=4)
# # Plotting the cumulants shows that there are significant # third and fourth cumulants in some places. # t <- (1:1024)/1024 plot(t, ppoly.wb$cumulants$one, type="l", xlab="t", ylab = "one") plot(t, ppoly.wb$cumulants$two, type="l", xlab="t", ylab = "two") plot(t, ppoly.wb$cumulants$three, type="l", xlab="t", ylab = "three") plot(t, ppoly.wb$cumulants$four, type="l", xlab="t", ylab = "four")
# # Now consider how much difference the prior can make. # Consider a smooth example, first using the default prior, # and then using a smoother prior. # gs <- sin(2*pi*t) + 2*(t - 0.5)^2 gs.noisy <- gs + rnorm(n=1024, sd=sqrt(var(gs))/2) gs.wb1 <- wave.band(data=gs.noisy)
gs.wb2 <- wave.band(data=gs.noisy, alpha=4, beta=1)