View source: R/ts_fil_spline.R
| ts_fil_spline | R Documentation |
Fit a cubic smoothing spline to a time series for smooth trend extraction with a tunable roughness penalty.
ts_fil_spline(spar = NULL)
spar |
smoothing parameter. When spar is specified, the coefficient of the integral of the squared second derivative in the fitting criterion (penalized log-likelihood) is a monotone function of spar. |
A ts_fil_spline object.
P. Craven and G. Wahba (1978). Smoothing noisy data with spline functions. Numerische Mathematik.
# Smoothing splines with adjustable roughness penalty
# Load package and example data
library(daltoolbox)
data(tsd)
tsd$y[9] <- 2 * tsd$y[9] # inject an outlier
# Fit spline smoother (spar controls smoothness) and transform
filter <- ts_fil_spline(spar = 0.5)
filter <- fit(filter, tsd$y)
y <- transform(filter, tsd$y)
# Compare original vs smoothed series
plot_ts_pred(y = tsd$y, yadj = y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.