View source: R/Transformations.R
| fcenLR | R Documentation |
Maps a density from the Bayes space B^2(\lambda) (densities
with respect to the Lebesgue measure \lambda on a bounded interval
[a, b]) to the space L^2(\lambda) of square-integrable functions,
\mathrm{fcenLR}_\lambda(f)(z) = \log f(z) - \frac{1}{b-a}\int_a^b \log f(t)\,dt.
This is the functional counterpart of the clr transformation (cenLR)
for compositions. The result integrates to zero over [a, b], so densities
can then be analysed with standard methods of functional data analysis.
fcenLR(z, z_step, density)
z |
numeric vector, equidistant grid of points on the domain |
z_step |
spacing of the grid |
density |
numeric vector of the same length as |
The integral is approximated by the trapezoidal rule (trapzc)
with spacing z_step, so z must be an equidistant grid with that
spacing; the domain length b-a is taken as max(z) - min(z).
Densities are scale invariant in the Bayes space: density does not need
to integrate to one, and fcenLR(z, z_step, c * density) equals
fcenLR(z, z_step, density) for any c > 0. All values of
density must be strictly positive; a zero anywhere on the grid makes the
whole result NaN.
Use fcenLRinv for the back-transformation, and fcenLRp
or fcenLRu for densities with respect to a reference measure
P other than the Lebesgue measure.
A numeric vector of the same length as density: the clr
transform evaluated on the grid. It integrates to zero over the domain.
R. Talska talskarenata@seznam.cz, A. Menafoglio, K. Hron karel.hron@upol.cz, J. J. Egozcue, J. Palarea-Albaladejo
Talska, R., Menafoglio, A., Hron, K., Egozcue, J. J., Palarea-Albaladejo, J. (2020). Weighting the domain of probability densities in functional data analysis. Stat. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1002/sta4.283")}
fcenLRinv, fcenLRp, fcenLRu,
trapzc, cenLR
# normal density on a grid
t <- seq(-4.7, 4.7, length = 1000)
t_step <- diff(t[1:2])
f <- dnorm(t, mean = 0, sd = 1.5)
f.fcenLR <- fcenLR(t, t_step, f)
trapzc(t_step, f.fcenLR) # zero integral
# the back-transformation returns the unit-integral version of f
f.back <- fcenLRinv(t, t_step, f.fcenLR)
f1 <- f / trapzc(t_step, f)
all.equal(f.back, f1)
plot(t, f.fcenLR, type = "l", las = 1, ylab = "fcenLR(density)",
col = "darkblue", lwd = 2)
abline(h = 0, col = "red")
plot(t, f.back, type = "l", las = 1, ylab = "density",
col = "darkblue", lwd = 2)
lines(t, f1, lty = 2, lwd = 2, col = "gold")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.