R/index.lfvar.R

Defines functions index.lfvar

Documented in index.lfvar

#' @title Proportion of variance in low frequency
#' @description Annual and seasonal proportion of variance in low frequency
#' @template templateIndexParams
#' @param lowVarPeriod Low frequency threshold. Minimum cycles per unit time below which frequency is considered as low
#' @param INDEX A Vector defining the aggregation periods (passed to \code{tapply}). No aggregation is performed by default.
#' @author Douglas Maraun \email{dmaraun@@geomar.de}
#' @export

index.lfvar <- function(ts, lowVarPeriod = 30, INDEX = 1:length(ts)) {
      mean.x <- tapply(ts, INDEX, mean, na.rm = TRUE)
      specVar <- spec.pgram(mean.x, na.action = na.exclude, plot = FALSE)
      lowfreqvar <- sum(specVar$spec[1/specVar$freq >= lowVarPeriod], na.rm = TRUE)
      totalvar <- sum(specVar$spec, na.rm = TRUE)
      lowfreqvar / totalvar
}
SantanderMetGroup/R_VALUE documentation built on July 4, 2023, 4:27 a.m.