Learn R Programming

IRISMustangMetrics (version 2.4.6)

dailyDCOffsetMetric: DC Offset Detection

Description

The dailyDCOffsetMetric() function identifies days with a jump in the signal mean.

Usage

dailyDCOffsetMetric(df, 
                    offsetDays=5,
                    outlierWindow=7,
                    outlierThreshold=3.0,
                    outputType=1)

Value

A list is returned with a SingleValueMetric object for the last day-floor(outlierWindow/2) (default 3rd from last day) in the incoming dataframe if outputType=1 (one list element), otherwise the first+offsetDays to last day-floor(outlierWindow/2) (multiple list elements, one per day) if outputType=0.

Arguments

df

a dataframe containing sample_mean values obtained with getSingleValueMetrics()

offsetDays

number of days used in calculating weighting factors

outlierWindow

window size passed to findOutliers() function in the seismicRoll package

outlierThreshold

detection threshold passed to findOutliers() function in the seismicRoll package

outputType

if 1, return last day of valid values (index= length(index)-floor(outlierWindow/2)); if 0, return all valid values (indices= max(offsetDays, floor(outlierWindow/2): length(index)-floor(outlierWindow/2))

Author

Jonathan Callahan jonathan@mazamascience.com

Details

This algorithm calculates lagged differences of the daily mean timeseries over a window of offsetDays days. Shifts in the mean that are persistent and larger than the typical standard deviation of daily means will generate higher metric values.

Details of the algorithm are as follows


# data0 = download requested daily means (in the 'df' dataframe), must be greater than max(offsetDays,outlierWindow)+floor(outlierWindow/2)
# data1 = remove outliers using MAD outlier detection with the 'outlier' arguments specified
# data2 = replace outliers with rolling median values using a default 7 day window, remove last floor(outlierWindow/2) number of samples.
# weights = calculate absolute lagged differences with 1-N day lags, default N=5
# metric0 = multiply the lagged differences together and take the N'th root
# stddev0 = calculate the rolling standard deviation of data2 with a N-day window
# METRIC = divide metric0 by the median value of stddev0

See Also

getSingleValueMetrics