dplR (version 1.7.1)

ffcsaps: Smoothing Spline with User-Specified Rigidity and Frequency Cutoff

Description

Applies a smoothing spline to y with rigidity determined by two parameters: frequency response f at a wavelength of nyrs years.

Usage

ffcsaps(y, x = seq_along(y), nyrs = length(y)/2, f = 0.5)

Arguments

y

a numeric vector, typically a tree-ring series.

x

a numeric vector with the same length as y, typically giving the years of y.

nyrs

a number greater than 1, affecting the rigidity of the spline. When f is kept constant, a larger nyrs produces a more rigid spline. Defaults to length(y)/2.

f

a number between 0 and 1 giving the frequency response at a wavelength of nyrs years. When nyrs is kept constant, a smaller f produces a more rigid spline: At one extreme, f = 0 causes the function to return the least-squares straight line fit to the data. At the other extreme, f = 1 results in the natural spline, i.e. the function outputs y. The default value is 0.5.

Value

A filtered vector.

Details

This applies a smoothing spline similar to the spline applied in most dendrochronological software. See references for more information. See ‘Examples’ for a pointer to a PDF document including mathematical details about the function.

References

Cook, E. R. and Kairiukstis, L. A., editors (1990) Methods of Dendrochronology: Applications in the Environmental Sciences. Springer. ISBN-13: 978-0-7923-0586-6.

See Also

hanning, detrend

Examples

Run this code
# NOT RUN {
library(graphics)
library(utils)
docFile <- system.file("doc", "math-dplR.pdf", package="dplR")
cat("See the following PDF for mathematical details:\n")
cat(docFile, sep="\n")
# }
# NOT RUN {
if (interactive() && requireNamespace("Biobase")) {
    Biobase::openPDF(docFile)
}
## Use series CAM011 from the Campito data set
data(ca533)
series <- ca533[, "CAM011"]
series <- series[!is.na(series)]
plot(series, type = "l", ylab = "Ring Width (mm)", col = "grey")
lines(ffcsaps(series, nyrs = 32), col = "red", lwd = 2)
lines(ffcsaps(series, nyrs = 64), col = "green", lwd = 2)
lines(ffcsaps(series, nyrs = 128), col = "blue", lwd = 2)
# }
# NOT RUN {
## Use first series from the Mesa Verde data set
data(co021)
series <- co021[, 1]
series <- series[!is.na(series)]
plot(series, type = "l", ylab = "Ring Width (mm)", col = "grey")
lines(ffcsaps(series, nyrs = 32), col = "red", lwd = 2)
lines(ffcsaps(series, nyrs = 64), col = "green", lwd = 2)
## nyrs defaults to 0.5*length(series) == 347
lines(ffcsaps(series), col = "blue", lwd = 2)
legend("topright",
       c("Series", "nyrs=32", "nyrs=64",
         paste("Default nyrs (", length(series) / 2, ")", sep="")),
       fill=c("grey", "red", "green", "blue"))
# }

Run the code above in your browser using DataLab