Skip to contents

Penalized Likelihood Smoothing

Usage

smooth_likelihood(x, y, ...)

# S4 method for class 'numeric,numeric'
smooth_likelihood(x, y, lambda, d = 2, SE = FALSE, progress = interactive())

# S4 method for class 'ANY,missing'
smooth_likelihood(x, lambda, d = 2, SE = FALSE, progress = interactive())

Arguments

x, y

A numeric vector. If y is missing, an attempt is made to interpret x in a suitable way (see grDevices::xy.coords()).

...

Currently not used.

lambda

An integer giving the smoothing parameter. The larger lambda is, the smoother the curve.

d

An integer specifying the order of the penalty.

SE

A logical scalar: should standard errors be returned?

progress

A logical scalar: should a progress bar be displayed?

Value

Returns a list with two components x and y.

Note

Matrix is required.

References

de Rooi, J. J., van der Pers, N. M., Hendrikx, R. W. A., Delhez, R., Böttger A. J. and Eilers, P. H. C. (2014). Smoothing of X-ray diffraction data and Ka2 elimination using penalized likelihood and the composite link model. Journal of Applied Crystallography, 47: 852-860. doi:10.1107/S1600576714005809

See also

Author

J. J. de Rooi et al. (original R code).

Examples

if (FALSE) { # \dontrun{
## X-ray diffraction
data("XRD")

## Subset from 20 to 40 degrees
XRD <- signal_select(XRD, from = 20, to = 40)

## Plot diffractogram
plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count")

## Penalized likelihood smoothing
lambda <- seq(from = 1, to = 8, length.out = 40)
lambda <- 10^lambda

likelihood <- smooth_likelihood(XRD, lambda = lambda, d = 3)
lines(likelihood, col = "red")

## Strip ka2
ka2 <- ka2_strip_penalized(XRD, lambda = lambda, tau = 0.5, nseg = 1)
lines(ka2, col = "blue")
} # }