detrendHeight: Remove trend from a time series

Description Usage Arguments Details Value Examples

View source: R/detrendHeight.R

Description

Fits a straight line to a vector of values using lm(), and uses the regression coefficients to subtract off the linear trend from the values.

Usage

1

Arguments

pt

A vector of numeric values to be detrended

Details

Typically this is used to remove a tidal trend from a ocean surface height time series before attempting to calculate statistics for waves, which are variations above and below the mean surface height. Returns a series of residuals around the linear trend, in the original units of measurement (typically meters).

Value

A list containing the following:

pt A vector of detrended values

seg_len The segment length used

h The mean height of the water column

trend A two element vector of the intercept and slope from the linear regression.

Examples

1
2
3
4
5
data(wavedata)
detrended <- detrendHeight(wavedata$swDepth.m)
pt <- detrended[['pt']]
plot(pt, type = 'l')
abline(h = 0)

Example output

Loading required package: ggplot2

oceanwaves documentation built on June 2, 2021, 9:08 a.m.