Detrend: Detrends a time series.

View source: R/Detrend.R

DetrendR Documentation

Detrends a time series.

Description

Detrends a time series using either a linear fit covering the entire dataset or moving average trend correction with a user-specified window width.

Usage

Detrend(Data, Method = "window", Window_Width = 89,
  End_Length = 1826, PLOT = FALSE, x_lab = "Data", y_lab = "Data")

Arguments

Data

Data frame containing two columns. In column:

  • 1 A "Date" object of equally spaced discrete time steps.

  • 2 Numeric vector containing corresponding time series values. No NAs allowed.

Method

Character vector of length one specifying approach used to detrend the data. Options are moving average "window" (default) and "linear".

Window_Width

Numeric vector of length one specifying length of the moving average window. Default is 89, window comprises the observation plus 44 days either side, which for daily data corresponds to an approximate 3 month window.

End_Length

Numeric vector of length one specifying number of observations at the end of the time series used to calculate the present day average. Default is 1826, which for daily data corresponds to the final five years of observations.

PLOT

Logical; whether to plot original and detrended series. Default is "FALSE".

x_lab

Character vector of length one specifying x-axis label. Default is "Date".

y_lab

Character vector of length one specifying y-axis label. Default is "Data".

Value

Numeric vector of the detrended time series.

Examples

#Detrending ocean-side water level at site S22 using a 3 month moving average window and the last
#five years of observations to calculate the present day average.
Detrend(S22_T_MAX_Daily_Completed_Detrend,Method = "window",Window_Width= 89,
        End_Length = 1826, PLOT=FALSE,x_lab="Data",y_lab="Data")

rjaneUCF/MultiHazard documentation built on March 29, 2025, 3:22 p.m.