tafa: Trend Analysis with Flow-Adjustment (TAFA)

Description Usage Arguments Details References See Also Examples

Description

Flow-adjust water quality data and perform a simple trend analysis with linear regression.

Usage

1
tafa(flow, constituent, dates, control = tafa.control())

Arguments

flow

A vector of flow data.

constituent

The constituent concentration data (vector) to analyze.

dates

A vector of sample dates. Should either be in POSIXct format or easily coerced by as.POSIXct

control

The control parameters. See tafa.control

Details

This function allows you to flow-adjust (i.e., remove the effect of stream flow) water quality data to aid trend analysis. The methodology follows the three step process outlined by White et al. (2004) and is modified by Simpson and Haggard (2016). The modification allows for the smoothing parameter of LOESS, which is used in the flow-adjustment, to be statistically optimized via a K-fold cross-validation procedure. This function is inspired by the 'loess.wrapper' function in the 'bisoreg' package (available on CRAN).

The flow-adjusted concentrations (FACs) are then modelled over time with simple linear regression to estimate the monotonic trend (interpreted as percent change per year). Other trend tests can also be performed on the FACs such as Kendall's Tau/Seasonal Kendall Test (slope can be estimated with the Sen slope estimator). See the 'zyp' and 'Kendall' packages available on CRAN.

References

Simpson, Z.P. and B.E. Haggard. 2016. An optimized procedure for flow-adjustment of constituent concentrations for trend analysis. In preparation.

White, K.L., B.E. Haggard, and I. Chaubey. 2004. Water quality at the Buffalo National River, Arkansas, 1991-2001. Transactions of the American Society of Agricultural Engineers 47(2):407-417.

See Also

loess, tafa, loess.wrapper

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#example dataset is from USGS station 07195430, total phosphorus data
summary(IR59)
IR59$Date <- as.POSIXct(IR59$Date) #convert the date column to a datetime format
IR59_tafa<-tafa(IR59$Flow_cfs, IR59$TP_mgL, IR59$Date)
#see the flow-adjustment process
plot(IR59_tafa$lnC ~ IR59_tafa$lnQ)
#add the fitted loess line
j <- order(IR59_tafa$lnQ) #have to order x-values for base plot
lines(IR59_tafa$lnQ[j], IR59_tafa$loess_fit$fitted[j], col="red", lwd=3)
#observe the flow-adjusted concentrations over time
plot(IR59_tafa$dates, IR59_tafa$FACs)
abline(lm(IR59_tafa$FACs~IR59_tafa$dates), col="blue") #note the decrease
#see percent change in TP over this period (% change per year)
IR59_tafa$perc_slope
#[1] -10.03825
IR59_tafa$p_val #we can say the linear regression slope is significant

arkansas-water-center/TAFA documentation built on May 10, 2019, 1:28 p.m.