https://github.com/cran/pracma
Raw File
Tip revision: 708a2ad382a163d1eef5af0665e3ae2aad200ced authored by HwB on 21 March 2013, 00:00:00 UTC
version 1.4.5
Tip revision: 708a2ad
whittaker.R
##
##  w h i t t a k e r . R  Whittaker Smoothing
##


whittaker <- function(y, lambda = 1600, d = 2) {
    warning("Not yet fully implemented (because of some strange behavior).
  See the example in 'savgol' for working code requiring the SparseM package.")
}

# whittaker <- function(y, lambda = 1600, d = 2) {
#     stopifnot(is.numeric(y))
# 
#     success <- require("SparseM", warn.conflicts = FALSE, quietly = TRUE)
#     # success <- library("SparseM", pos = "package:base",
#     #                    logical.return = TRUE, warn.conflicts = FALSE)
#     if (!success)
#       stop("Function 'whittaker' requires package 'SparseM' to be installed.")
# 
#     m <- length(y)
#     E <- as(m, "matrix.diag.csr")
#     class(E) <- "matrix.csr"
# 
#     Dmat <- diff(E, differences = d)
#     B <- E + (lambda * t(Dmat) %*% Dmat)
#     z <- solve(B, y)
# 
#     return(z)
# }
back to top