smooth_wWHIT: Weigthed Whittaker Smoother

View source: R/smooth_wWHIT.R

smooth_wWHITR Documentation

Weigthed Whittaker Smoother

Description

Weigthed Whittaker Smoother

Usage

smooth_wWHIT(
  y,
  w,
  ylu,
  nptperyear,
  wFUN = wTSM,
  iters = 1,
  lambda = 15,
  second = FALSE,
  ...
)

Arguments

y

Numeric vector, vegetation index time-series

w

(optional) Numeric vector, weights of y. If not specified, weights of all NA values will be wmin, the others will be 1.0.

ylu

⁠[low, high]⁠ of time-series y (curve fitting values are constrained in the range of ylu.

nptperyear

Integer, number of images per year.

wFUN

weights updating function, can be one of 'wTSM', 'wChen' and 'wBisquare'.

iters

How many times curve fitting is implemented.

lambda

scaler or numeric vector, whittaker parameter.

  • If lambda = NULL, V-curve theory will be applied to retrieve the optimal lambda.

  • If multiple lambda provided (numeric vector), a list of the smoothing results with the same length of lambda will be returned.

second

If true, in every iteration, Whittaker will be implemented twice to make sure curve fitting is smooth. If curve has been smoothed enough, it will not care about the second smooth. If no, the second one is just prepared for this situation. If lambda value has been optimized, second smoothing is unnecessary.

...

Additional parameters are passed to wFUN.

Value

  • ws: weights of every iteration

  • zs: curve fittings of every iteration

Note

Whittaker smoother of the second order difference is used!

References

  1. Eilers, P.H.C., 2003. A perfect smoother. Anal. Chem. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1021/ac034173t")}

  2. Frasso, G., Eilers, P.H.C., 2015. L- and V-curves for optimal smoothing. Stat. Modelling 15, 91-111. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1177/1471082X14549288")}.

See Also

lambda_vcurve()

Examples

data("MOD13A1")
dt <- tidy_MOD13(MOD13A1$dt)
d <- dt[site == "AT-Neu", ]

l <- check_input(d$t, d$y, d$w, nptperyear=23)
r_wWHIT <- smooth_wWHIT(l$y, l$w, l$ylu, nptperyear = 23, iters = 2)

## Optimize `lambda` by V-curve theory
# (a) optimize manually
lambda_vcurve(l$y, l$w, plot = TRUE) 

# (b) optimize automatically by setting `lambda = NULL` in smooth_wWHIT
r_wWHIT2 <- smooth_wWHIT(l$y, l$w, l$ylu, nptperyear = 23, iters = 2, lambda = NULL) # 

phenofit documentation built on May 29, 2024, 2:39 a.m.