Description Usage Arguments Details Value Note See Also Examples
The fracdet
class represents a wavelet transform that is assumed to
be modelled by a simple fractal-deterministic model with long-memory
properties. The model consists on a linear superposition of a fractional
brownian motion (fBm) B and a deterministic band-limited signal
x. That is, the observed signal is Y = x + B. The fracdet
receives as parameters the wavelet transform of Y and an R fitted model
object (nls
or lm
) containing the estimation of the parameters
characterizing the fBm (The Hurst exponent H and the "dispersion"
parameter sigma ^ 2). The main method of the fracdet
class
is estimateDetSignal
, which permits the estimation of the deterministic
signal x using bayesian modelling techniques in the wavelet-domain.
1 | fracdet(x, fbmPars)
|
x |
A |
fbmPars |
Either a |
In addition to the specific methods for the fracdet
class, all the
wd
methods can be used with a fracdet
object.
A S3 fracdet
object that represents the observed Y signal
in the wavelet domain. The fracdet
object will also contain the
estimates of the fBm parameters.
When computing the wavelet transform of the Y signal through the
wd
method (see wd
) we recommend using the
"symmetric" boundary handling method (bc == "symmetric"
) if
H > 0.5.
waveletVar
, getWaveletVar
,
getWaveletVarModel
, getFittedWaveletVar
,
as.wd
, estimateDetSignal
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | ## Not run:
### deterministic signal estimation
# set parameters for the example
set.seed(3)
nlevels = 14
n = 2 ^ nlevels
xlim = c(200, 400)
H = 0.3
# simulate a simple fbm + sinusal signal
x = 1.25 * cospi(2 * 1:n / 10)
y = fbmSim(n = n, H = H) + x
plot(y, xlim = xlim,
ylim = range(y[xlim[[1]]:xlim[[2]]]),
type = "l")
lines(x, lty = 2, col = 2)
legend("topright", lty = 1:2, col = 1:2,
legend = c("Y", "x"), bty = "n")
# compute the wavelet transform and the wavelet coefficients' variances
wy = wd(y, bc = "symmetric")
vpr = waveletVar(wy)
# do you note the increase in variance in level 11?
plot(vpr, xlim = c(4, nlevels - 1),
ylim = range(vpr[5:nlevels]))
# estimate the fBm parameters avoiding levels 11 and 12 (with deterministic
# contributions). Level 12 is also avoid as a precaution
model = estimateFbmPars(vpr, use_resolution_levels = c(5:10, 13))
# Create a fracdet object...
fd = fracdet(wy, model)
# ... and check the fbm parameters estimates
coef(fd)
# A plot of the fitted variances may be useful
plot(getWaveletVar(fd))
points(getFittedWaveletVar(fd),
col = 2,
pch = 2)
# we could also extract the nls-fit and use the predict function
# The nls-fit is performed in semilog-space. Thus, a transformation
# of the predicted values is required
nls_model = getWaveletVarModel(fd)
points(resolutionLevels(vpr),
2 ^ predict(nls_model, newdata = data.frame(x = resolutionLevels(vpr))),
col = 3,
pch = 3)
# Estimate the deterministic signal (this may take a while) taking
# into account the deviations in level 11, 12. The estimateDetSignal uses
# this information using a Bayesian modelling approach
wx = estimateDetSignal(fd, estimate_from = 11:12)
x_est = wr(wx)
# compare the original signal and the estimation
old_par = par(mfrow = c(2,1))
plot(y, xlim = xlim,
ylim = range(y[xlim[[1]]:xlim[[2]]]),
type = "l")
lines(x, lty = 2, col = 2)
legend("topright", lty = 1:2, col = 1:2,
legend = c("Y", "x"), bty = "n")
plot(x, type = "l", xlim = xlim,
ylim = range(x) * c(1, 2))
lines(x_est, col = 2, lty = 2)
legend("topright", lty = 1:2, col = 1:2,
legend = c("x", "x estimate"), bty = "n")
par(old_par)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.