Statistical Tools For Analyzing Water Quality Data
Statistical Tools For Analyzing Water Quality Data
Statistical Tools For Analyzing Water Quality Data
net/publication/224829937
CITATIONS READS
23 17,044
2 authors:
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by You-Gan Wang on 30 May 2014.
1. Introduction
Water quality data are often collected at different sites over time to improve water
quality management. Water quality data usually exhibit the following characteristics:
non-normal distribution, presence of outliers, missing values, values below detection limits
(censored), and serial dependence. It is essential to apply appropriate statistical methodology
when analyzing water quality data to draw valid conclusions and hence provide useful
advice in water management. In this chapter, we will provide and demonstrate various
statistical tools for analyzing such water quality data, and will also introduce how to use
a statistical software R to analyze water quality data by various statistical methods. A
dataset collected from the Susquehanna River Basin will be used to demonstrate various
statistical methods provided in this chapter. The dataset can be downloaded from website
http://www.srbc.net/programs/CBP/nutrientprogram.htm.
2.1 Boxplots
A boxplot is a very useful and convenient tool to provide summaries of a dataset and is
often used in exploratory data analysis. A boxplot usually presents a dataset through five
numbers: extreme values (minimum and maximum values), median (50th percentile), 25th
percentile, and 75th percentile. It also indicates the degree of dispersion, the degree of skew,
and unusual values of the data (outliers). Furthermore, boxplots can display differences
* Address
for correspondence: Centre for Applications in Natural Resource Mathematics (CARM), School of
Mathematics and Physics, the University of Queensland, St Lucia, QLD 4072, Australia
144
2 Water Quality Monitoring and Assessment
Will-be-set-by-IN-TECH
between different populations without making any assumptions of the underlying statistical
distribution. Boxplots of concentrations of total phosphorus (mg/L) at four stations from the
Susquehanna River Basin from 2005 to 2010 are constructed (Fig. 1). R codes for constructing
Fig. 1 are as follows:
> yl<- “Concentrations of total phosphorus (mg/L)”
> boxplot(TP ∼ Station, ylab = yl, data = dat, boxwex = 0.5, outline = TRUE)
In Fig. 1, it can be seen that the four stations have nearly identical median values, and outliers
could be present at all four stations. The distributions are right skewed. Further details on
construction of a boxplot can be found in McGill et al. (1978), and Tukey (1977). More details
for plotting boxplots are available in Adler (2009), Crawley (2007), and Venables & Ripley
(2002).
1.0
Concentrations of total phosphorus (mg/L)
0.8
0.6
0.4
0.2
0.0
Fig. 1. Boxplots for total phosphorus at four stations at the Susquehanna River Basin
A scatter plot is a very useful summary of a set of bivariate data (two variables), usually
drawn before obtaining a linear correlation coefficient or fitting a regression line. It can be
used to detect whether the relationships between two variables are linear or curved, and aids
the interpretation of the correlation coefficient or a regression model. Fig. 2 is a scatter plot of
the concentration of total phosphorus (mg/L) versus instantaneous flow (feet3 /s) in log scale
at Station 1.
> xl<- “Instantaneous flow on log scale in cubic feet per second”
> plot(log(UNA$Flow), UNA$TP, xlab = xl, ylab = yl)
> points(log(UNA$Flow)[39], UNA$TP[39], col=2, pch =16)
> points(log(UNA$Flow)[18], UNA$TP[18], col=2, pch =16)
> points(log(UNA$Flow)[50], UNA$TP[50], col=2, pch =16)
Statistical Tools
Statistical Tools for for
Analyzing Analyzing
Water Quality Data Water Quality Data 1453
We can generate a scatter plot using the data from two stations and can also use the function
0.30
Concentrations of total phosphorus (mg/L)
0.25
0.20
0.15
0.10
0.05
0.00
5 6 7 8 9
Fig. 2. Scatter plot of total phosphorus and instantaneous flow at Station 1, three possible
outliers are in red
xyplot (Venables & Ripley, 2002) to split the data into different panels based on station (Fig. 3
(a), (b)).
> plot(log(UNA$Flow), UNA$TP, xlab = xl, ylab = yl, type = “p”, pch = 1, col = 1)
> points(log(CKL$Flow), CKL$TP, pch = 3, col = 2)
> legend(4.5, 0.3, c(“Station 1”, “Station 2”), pch = c(1, 3), col=c(1, 2))
> library(lattice)
> xyplot(TP ∼ log(Flow)|Station, data = dat, xlab = xl, ylab = yl, col = 1)
Concentration varies with natural log of instantaneous flow, as illustrated using a scatter plot.
A linear regression model could be used to fit the data in Fig. 2, but true changes in slope are
difficult to detect from only a scatter plot. Various methods have been developed to construct
a central line to detect variation of slope locally in response to the data themselves, such as the
locally weighted scatter plot smoothing (LOWESS) method (Fig. 4) (Cleveland et al., 1992).
> plot(log(UNA$Flow), UNA$TP, xlab = xl, ylab = yl)
> lines(lowess((UNA$TP) ∼ log(UNA$Flow)), col=2)
4 6 8 10
Station 3 Station 4
1.0
0.30
0.8
Station 1
Station 2
Concentrations of total phosphorus (mg/L)
0.6
0.4
0.2
0.20
0.0
Station 1 Station 2
0.15
1.0
0.8
0.10
0.6
0.05
0.4
0.2
0.00
0.0
5 6 7 8 9
4 6 8 10
Instantaneous flow on log scale in cubic feet per second Instantaneous flow on log scale in cubic feet per second
0.25
0.20
0.15
0.10
0.05
0.00
5 6 7 8 9
Fig. 4. The data of Fig. 2 fitted with the locally weighted scatter plot smoothing method
normal, respectively.
> qqnorm(UNA$TP); qqline(UNA$TP, col = 2)
> qqnorm(log(UNA$TP)); qqline(log(UNA$TP), col = 2)
−1.0
0.30
−1.5
0.25
−2.0
Sample Quantiles
Sample Quantiles
0.20
−2.5
0.15
−3.0
0.10
−3.5
−4.0
0.05
−4.5
0.00
−2 −1 0 1 2 −2 −1 0 1 2
(a) (b)
Fig. 5. A Q-Q plot of total phosphorus concentrations at Station 1 versus the standard normal
distribution
Fig. 5 (a) indicates that the distribution of total phosphorus concentrations is skewed to the
right. Fig. 5 (b) shows an S-shape, but there is not sufficient evidence to prove that the
distribution of total phosphorus on the natural log scale is non-normal. Fig. 6 is a Q-Q plot
comparing whether two sample datasets are from populations with a common distribution.
Note that there are also a few outliers appearing (possible outliers are in red). Otherwise, the
plot suggests that the two samples have the same distribution.
> qq <-qqplot(UNA$TP, CKL$TP, plot.it = TRUE, xlab = “Concentrations of total phosphorus
at Station 1”, ylab =“Concentrations of total phosphorus at Station 2”)
> points(qq$x[85],qq$y[85], pch=16, col=2)
> points(qq$x[84],qq$y[84], pch=16, col=2)
> points(qq$x[83],qq$y[83], pch=16, col=2)
0.5
Concentrations of total phosphorus at Station 2
0.4
0.3
0.2
0.1
0.0
Fig. 6. A Q-Q plot comparing distributions of total phosphorus at Station 1 and Station 2
Water quality indices have been employed frequently in the public domain to assess water
quality, such as the US National Sanitation Foundation Water Quality Index (Brown et al.,
1970), the Canadian Water Quality index (CCME, 2001), the British Columbia Water Quality
Index (Zandbergen & Hall, 1998) and the Oregon Water Quality Index (Cude, 2001). Main
steps to derive a water quality index are as follows: select the most important water
quality parameters (such as dissolved oxygen, total phosphorus, temperature); transform
the parameters into a common scale; assign parameter weights; and aggregate scores to
a single score. In this section, various water quality indices, such as those based on the
weighted/unweighted arithmetic/geometric/harmonic mean functions, will be presented
and compared. Their uses and limitations will be also discussed.
Let k = 1 in Equation (1). In general, we have the objective water quality index originally
proposed by Horton (1965), hereafter called the weighted arithmetic water quality index. It
has been used by many researchers (Brown et al., 1970; Prati et al., 1971; Sanchez et al., 2007):
n
WQIWA = ∑ ω i Si . (2)
i =1
The third water quality index is based on the weighted geometric mean function (Brown et al.,
1970; McClelland, 1974), which is always smaller than WQIWA if all values of Si are positive:
n
WQIW G = ∏ Siω . i
(3)
i =1
The above weighted water quality indices indicate that each water quality parameter may
have different weights based on the importance of the water quality situation. This
characteristic could be desirable when water quality indices are specific to the protection
of aquatic life. However, when sensitivity to changes in each water quality parameter
is more desirable than sensitivity to the most heavily weighted water quality parameter,
such weighting could be unnecessary (Cude, 2001; Gupta et al., 2003; Landwehr & Deininger,
1976). Some unweighted water quality indices were therefore explored (Cude, 2001;
Dojlido et al., 1994; Landwehr & Deininger, 1976) and are now introduced in the following
subsection.
n
WQIG = ( ∏ Si )1/n , (5)
i =1
which is a special case of (2) and (3) with ω i = 1/n for any i, respectively. As with the
relationship between WQIW G and WQIWA, WQIG is always lower than WQI A . The third is
the harmonic square water quality index,
n
WQIH = , (6)
∑i=1 S12
n
i
which has been suggested as an improvement over both WQIWA and WQIW G (Cude, 2001;
Dojlido et al., 1994). Compared to WQIWA and WQIW G, WQIH is the most sensitive to
changes in single water quality parameter (Cude, 2001).
n
( Ri − Ric )2
WQIHR = ∑ var ( Ri )
, (7)
i =1
where
ki
1
var ( Ri ) = [( M3 − M ) − ∑ (t3ij − tij )],
12M j =1
Ri and Ric correspond to the rank and control values of the ith water quality parameter,
respectively. M is the number of water quality parameters plus the number of control
values, tij is the number of elements involved in the jth tie encountered when ordering
the measured values of the ith water quality parameter, and k i is the total number of ties
encountered in ranking the measurements of the ith parameter. Landwehr & Deininger
(1976) and Gupta et al. (2003) compared WQIHR with water quality indices WQIWA, WQIW G ,
WQIG , and WQI A . Their results indicated that these five indices are correlated well with the
opinions of experts, and although the five indices showed significant correlation with each
other, WQIHR was the lowest of the five. Therefore, they suggested adopting any of the four
indices except WQIHR.
where θ is a vector of parameter, f (·) is the probability density function of y, and F (·) is the
cumulative density function (c.d.f.) of y. The parameter estimates of θ and summary statistics
can be obtained by the maximum likelihood method (ML) (Cohen, 1976; Cohn, 1988; Helsel,
1992). Results based on a lognormal distribution assumption by the maximum likelihood
method can be easily obtained using statistic software R (NADA package) (Lee & Helsel,
2005). If the distributional assumption is appropriate and the sample size is large, the
maximum likelihood method is the most efficient (Cohn, 1988; Helsel, 1992; Hewett & Ganser,
2007). To incorporate the covariate effects when analyzing the water quality data that fall
below detection limits, the following regression models can be considered.
log(y∗i ) = β0 + β1 xi + i , (9)
where y∗ is a latent variable and yi = y∗i if y∗i > ci and yi = ci otherwise. Random error term
i follows a normal distribution N (0, σ2 ). The likelihood function (8) can be written as
δi 1−δi
1 log(yi ) − β0 − β1 xi log(ci ) − β0 − β1 xi
L ( β0 , β1 ) = ∏ σ
φ
σ ∏ Φ
σ
,
i i
where δi = 1 if y∗i
> ci and δi = 0 otherwise. The maximum likelihood estimates (MLE) of
parameters can be obtained from the function survreg (survival package) and vglm (VGAM
package) in R if the detection limit is a single number. An example to obtain MLE of
parameters in a Tobit regression model log(DP) = β0 + β1 log(Flow) + is given,
> library(survival)
> fit<- survreg(Surv(log(DP), DP>=0.01, type = ‘left’) ∼ log(Flow), data = UNA, dist =
‘gaussian’)
> summary(fit)
For multiple detection limits, the estimates can be derived by a Newton-Raphson algorithm.
The Wald type test or the likelihood ratio test can be applied to test the group difference
or covariate effects (by testing β = 0). Tobit regression is also applicable when both the
measurements of the response and covariate variable are with detection limits (Helsel, 1992).
When the distribution is known and the error terms are homeostatic, the estimate derived by
the maximum likelihood method is optimal (Helsel, 2005b).
152
10 Water Quality Monitoring and Assessment
Will-be-set-by-IN-TECH
(1 − pi )1−ỹi ,
ỹ i
L ( α0 , α1 ) = ∏ pi
i
95
90
75
50
25
10
5
0.100
0.050
0.020
Value
0.010
0.005
0.002
−2 −1 0 1 2
Normal Quantiles
Fig. 7. A normal Q-Q plot for a ROS model. Solid circles are detected data. Open circles are
modeled undetected values.
4.3.1 Kaplan-Meier
The Kaplan-Meier (K-M) method is the standard method for computing descriptive statistics
of data that fall below detection limits (Helsel, 2005; Lee & Helsel, 2007). K-M method
has been widely used in survival analysis, where it is employed with right-censored
time-to-failure data. The K-M method can estimate the percentiles or c.d.f. for a dataset,
and can test hypotheses. It can describe and compare the shapes of different datasets (Figs. 8
(a) and (b)).
> KM<- cenfit(UNA$OP, UNA$CenOP)
> plot(KM)
> dat2<- dat2[!is.na(dat2$OP), ]
> dat2$CenOP<- dat2$OPrem == “<”
> g2<- cenfit(dat2$OP, dat2$CenOP,dat2$Station)
> plot(g2,lty = c(1 : 3), col=c(1, 2, 4))
> legend(0.002, 0.8, c(“Station 1”,“Station 2”,“Station 4”), lty = c(1:3), col=c(1, 2, 4))
154
12 Water Quality Monitoring and Assessment
Will-be-set-by-IN-TECH
1.0
1.0
0.8
0.8
Station 1
Station 2
Station 4
0.6
0.6
Probability
Probability
0.4
0.4
0.2
0.2
0.0
0.0
0.002 0.005 0.010 0.020 0.050 0.100
0.002 0.005 0.010 0.020 0.050 0.100
Value Value
(a) Dashed lines are 95% confidence (b) Empirical c.d.f at three stations
limits
Fig. 8. Empirical cumulative distribution functions for datasets with multiple detection limits
Zhang et al. (2009) developed a nonparametric estimation procedure, and under a fixed
detection limit and some mild conditions, they established the theoretical equivalence of three
nonparametric test statistics: the Wilcoxon rank sum, the Gehan, and the Peto-Peto tests.
Their simulation studies indicated that nonparametric methods work well for a range of small
sizes and censoring rates (Zhang et al., 2009). For hypothesis testing with multiple detection
limits, one robust method is to censor all data at the highest detection limit and then perform
an appropriate nonparametric test (Helsel, 1992). This can result in a loss of information,
however, the accelerated failure time (AFT) model can integrate the Gehan and logrank tests,
incorporate covariate effects, and compare the differences between two/multiple data groups
with multiple detection limits (Jin et al., 2006; Wei, 1992; Zhang et al., 2009).
Zi = Xi β + i ,
where ω (ei ) is a weight function and ei = log(Yi ) − Xi β t , where β t is the true value of β.
Let ω (ei ) = 1 and ω (ei ) = ∑ Nj =1 I ( e i ≥ e j ); U ( β) correspond to the log-rank and Gehan
Statistical Tools
Statistical Tools for for
Analyzing Analyzing
Water Quality Data Water Quality Data 155
13
statistics, respectively. The estimating functions U ( β) are step functions and discontinuous
in the regression parameters, which makes it difficult to find consistent estimators and their
asymptotic variance and covariance matrices. Much progress has been made to overcome
these difficulties (Brown & Wang, 2006; Heller, 2007; Jin et al., 2003; Lee et al., 1993), and the
function lss (lss package) can be used to obtain various statistics from an AFT model.
> library(lss)
> UNA$status<- 1-(UNA$OPrem==“<”)
> aftfit<- lss(cbind(log(OP), status)∼ log(Flow), data=UNA, gehanonly=FALSE, cov=TRUE)
> print(aftfit)
Jin et al. (2006b) extended marginal accelerated failure time models to multivariate censored
data. Their method, which is based on an independence “working" model, may ignore
the within-site correlations in obtaining parameter estimates, while taking account of
the correlation in calculating the standard errors. More efficient estimators with similar
computational complexity were developed for multivariate censored data analysis, when
measurements from the same site exhibit strong temporal correlations (Fu & Wang, 2011).
5. Trend detection
In recent years, concentrations of various water quality parameters have been collected.
Tests for trends specific to various water quality parameters have been of keen interest in
environmental science (Helsel, 1992). A number of methods have been proposed to detect
and assess changes in water quality. In this section, a variety of approaches will be introduced
and their strengths and weaknesses investigated. The exogenous variable effects and serial
dependence will be considered when testing water quality trends.
Y = β0 + β1 T + , (10)
where β1 is the rate of change in Y. The null hypothesis for testing the trend of y can be stated
as a test for β1 = 0. The Wald type statistic (t-statistic) can be used. If the null hypothesis
is rejected, it indicates that there is a linear trend in Y over time. If Y is not linear over time
T, some transformation of Y, such as a log transformation, may be necessary. An example
using a linear regression to detect the trend of total phosphorus concentrations at Station 1 is
presented in Fig. 9. The results indicate that the trend of total phosphorus is not significant.
0.30
Concentrations of total phosphorus (mg/L)
0.25
0.20
0.15
0.10
0.05
0.00
Time
activities such as agriculture (Helsel, 1992; Hirsch et al., 1991). Therefore, it is important
to consider seasonal effects when evaluating changes in water quality data. In parametric
procedures, multiple regression with periodic functions can be used to describe seasonal
variation. Consider the following simple case,
where T is expressed in years and β1 indicates the change rate of Y. Terms sin(2πT ) and
cos(2πT ) capture the annual cycle and account for seasonality. Residuals must follow a
normal distribution (or approximately normal). The trend test can be constructed by testing
β1 = 0.
If residuals still show a seasonal pattern (see Fig. 11), additional periodic functions should be
included in model (11) to remove the seasonal variation. A general multiple linear regression
is given by
K
Y = β0 + β1 T + ∑ [ β2k+1 cos(2πkT ) + β2k+2 sin(2πkT )] + . (12)
k =0
The cases of K = 0 and K = 1 correspond to model (10) and (11). If K = 2, a period of 1/2 year
is then also included in model (12). Fig. 11 shows that the residuals of the linear regression in
Subsection 5.1.1 represent a seasonal pattern, therefore periodic functions should be included
in the model.
When Y or some transformation of Y is linear with time T, and residuals follow a normal
distribution with a constant variance, the parametric regression is optimal. However, the
Statistical Tools
Statistical Tools for for
Analyzing Analyzing
Water Quality Data Water Quality Data 157
15
0.30
Concentrations of total phosphorus (mg/L)
0.25
0.20
0.15
0.10
0.05
0.00
Time in years
0.05
0.00
−0.05
Time
Fig. 11. Residuals of the linear regression mentioned in above subsection versus times in year.
distribution of water quality data is usually highly skewed, in particular, data related to
discharge, as well as biological indicators (biomass, chlorophyll) (Helsel, 1992; Hirsch & Slack,
158
16 Water Quality Monitoring and Assessment
Will-be-set-by-IN-TECH
1984). The test that depends on the normality assumption may be inappropriate. The
following subsection introduces several nonparametric methods that do not require the
normality assumption.
where
⎧
⎨ 1 if θ > 0
sgn(θ ) = 0 if θ = 0
⎩
−1 if θ < 0.
Under the null hypothesis, Mann (1945) and Kendall (1975) obtained the mean and variance
of S.
E (S ) = 0,
where t is the extent of any given tie (number of xs involved in a given tie) and ∑t denotes the
summation over all ties.
Both Mann (1945) and Kendall (1975) derived the exact distribution of S for n ≤ 10; proved
that the distribution of S is normal as n → ∞; and further showed that even for n = 10, the
normal approximate is excellent if one calculates the standard normal variate Z by
⎧ S −1
⎨ {var( S)}1/2 if S > 0
⎪
Z= 0 if S = 0
⎪
⎩ S +1
{var( S)} 1/2 if S < 0.
Hence, in a two-sided test for trend, the H0 should be rejected if | Z | ≥ zα/2 , where Φ (zα/2 ) =
1 − α/2, Φ (·) is the standard normal c.d.f. and α is the significance level for the test. A position
value of S indicates an “upward” trend, and a negative value of S presents a “downward”
trend. For an example from Station 21 at Susquehanna River basin (Fig. 10), the statistic
Statistical Tools
Statistical Tools for for
Analyzing Analyzing
Water Quality Data Water Quality Data 159
17
S = −90, the var(S ) = 1096.67 under the null hypothesis and the p value is 0.0072, which
indicates a downward trend in the concentration of total phosphorus at Station 21.
> library(Kendall)
> TP<- ts(CONY$TP, frequency=1, start=1990)
> mk<- MannKendall(TP)
> summary(mk)
The seasonality is a common phenomenon, which indicates that the distributions differ
for different times of year. The Mann-Kendall test therefore is sensitive to seasonality.
Hirsch et al. (1982) developed a modified Mann-Kendall test to detect the trend of data with
seasonality.
E (Si ) = 0,
The distribution of Si is normal as n i → ∞ (ti is the extension of a given tie in month i). Define
the seasonal Kendall statistic
m
S∗ = ∑ Si , (14)
i =1
and variance
m m m
var(S ∗ ) = ∑ var(Si ) + ∑ ∑ cov(Si , S j ). (15)
i =1 i =1 j = i
160
18 Water Quality Monitoring and Assessment
Will-be-set-by-IN-TECH
The approximation is adequate for n i = 3 and m = 12 for all i (Hirsch et al., 1982). For the
example from Station 21 at Susquehanna River basin (Fig. 10), the statistic S ∗ = −360, the
var (S ) = 10779.67 under the null hypothesis, and the p value is 0.0005, which indicates a
downward trend in the concentration of total phosphorus at Station 21.
> library(Kendall)
> TPS<- ts(c(t(RCON[,-1])), frequency = 12, start = c(1990, 1))
> smk<- SeasonalMannKendall(TPS)
> summary(smk)
A limitation of the seasonal Kendall test is one observation per month. If there are multiple
observations in each of the months, Hirsch et al. (1982) suggested using the medians of
the multiple observations in the seasonal Kendall test. Another limitation is that the
seasonal Kendall test is not robust against serial dependence. When serial dependence exists,
cov(Si , S j ) in Equation (15) does not equal zero. Hirsch & Slack (1984) provided a modification
of the seasonal Kendall test which is robust against serial dependence, except when the data
have very strong long-term persistence or when the sample sizes are small. More details can
be found in Hirsch & Slack (1984) and Letternmatier (1988). In addition to detecting the trend,
the magnitude of such a trend may also be desirable. In model (10), an estimate of β1 can be
used to estimate the trend. For a seasonal Kendall test, calculate dijk = ( Xij − Xik )/( j − k) for
all pairs ( Xik , Xij ) and (k < j). Hirsch et al. (1982) proposed using the median of dijk as an
estimator of the slope, which is robust against extreme values.
where Ri+ = ∑ j Rij /n and R+ j = ∑i Rij /m. Under the null hypothesis of no trend, the
distribution of T tends to the standard normal distribution. Simulation results indicated
that the normal approximation for the statistic T was reasonable even for a small sample
(Van Belle & Hughes, 1984).
Statistical Tools
Statistical Tools for for
Analyzing Analyzing
Water Quality Data Water Quality Data 161
19
The three nonparametric methods for detecting trends mentioned above have practically the
same power at a statistical significance level of 0.05 (Yu et al., 1993). It is worth noting that
there may exist water quality parameters which exhibit strong evidence of a download trend
in some months and then exhibit strong evidence of an upload trend (step trend) (Helsel, 1992;
Hirsch et al., 1991). The methods described above all assume a single trend across all seasons,
provide a summary statistic for the entire record (monotonic trend), and do not indicate
when there are trends in opposing directions in different months. Van Belle & Hughes (1984)
developed a statistic for testing homogeneity of trends. The statistic is
m
χ2homogeneous = χ2total − χ2trend = ∑ Zi2 − mZ̄2 ,
i =1
5 6 7 8 9
−2
−4
−2
−3
−4
5 6 7 8 9 5 6 7 8 9
Fig. 12. Log values of total phosphorus concentration (C) versus log values of flow (F)
The results indicate an annual cycle and flow effect exist (p<0.05). After adjusting exogenous
variables effects, the concentration of total phosphorus significantly decreases (p = 0.02).
considered to be tied with each other. The nonparametric procedures such as Mann-Kendall,
and the seasonal Kendall statistics can be used directly. If multiple detection limits exist,
censor the data at the highest detection limit and then use an appropriate method to test the
trend. Some information is certainly lost by making this change.
No exogenous covariate (X) effects
No seasonality Seasonality
Parametric Regression of Y on T Regression of Y on T and Seasonal terms
Nonparametric M-K test S-K test
Mixed S-K test on residuals from regression of Y on X
Exogenous covariate (X) effects exist
No seasonality Seasonality
Parametric Regression of Y on ( T, X ) Regression of Y on ( T, X, S )
Nonparametric M-K of residuals from regression of Y on ( T, X ) S-K of residuals from lowess of Y on X
Mixed M-K of residuals from regression of Y on ( T, X ) S-K of residuals from regression of Y on ( T, X, S )
Table 1. Classification of various types of tests for monotonic trend. M-K indicates
Mann-Kendall test, S-K indicates Seasonal Kendall test, and S denotes seasonal terms.
example, a slightly different model is used to fit the data above, which considers an extra
covariate “Temp” besides “Flow” and “pH”.
> con.lm2<-update(con.lm, . ∼ . + Temp)
To compare models con.lm and con.lm2 which are used to fit the same dataset, use the anova
function:
> anova(con.lm, con.lm2)
The main arguments to the function lm are
> lm(formula, data, weights, subset, na.action),
where formula is the model formula that specifies the form of the model to fit; data is an
optional data frame containing the variables in the model; weights is a positive numeric vector
containing weights to be used in the fitting process; subset is an optional vector specifying
a subset of observations to be used in the fitting process; and na.action is a function which
indicates how to handle missing values contained in the data.
The least-squares method performs well when the following key assumptions are satisfied: (1)
There is a linear relationship between any pair of covariate variables (linearity); (2) The error
terms are normally distributed (normality) with a constant variance (homoscedasticity); (3)
The error terms are not correlated with each other (autocorrelation). However, because these
assumptions may not be met in water quality data, linear regression is therefore not always
appropriate. The test functions can be used to check these assumptions in R. The function
ncv.test in the car package can be used to test the homoscedasticity. The function durbin.watson
(car package) is used to test autocorrelation in a linear regression model. Diagnostic plots can
also provide checks for homoscedasticity, normality, and influential observations (see Fig. 13),
which can be obtained using the function plot(con.lm).
Standardized residuals
1.5
51
54
51
1
Residuals
1.0
0
0.5
−1
54
0.0
−4.0 −3.5 −3.0 −2.5 −2.0 −4.0 −3.5 −3.0 −2.5 −2.0
Standardized residuals
51 51
2
2
40
1
1
0
0
−1
−1
−2
38
Cook’s distance
−2
54
6. Conclusions
Statistical methods are important in water quality analysis because much of what is known
about water quality comes from numerical datasets. In this chapter, various statistical
methods for analyzing water quality data have been introduced. Three typical graphs,
boxplots, Q-Q plots, and scatter plots, which contain appropriate summarized information
about datasets, are used to provide insight for analysts into datasets. A variety of classic
water quality indices are applied to give a global assessment of water quality. Weighted water
quality indices are relatively subjective; unweighted water quality indices and Harkins’ water
quality index are more objective. Other more advanced methods can be found in Raican et al.
(2011) and Qian et al. (2007). To handle water quality data with detection limits, simple
substitution methods as well as parametric and nonparametric approaches are investigated.
Substitution methods are simple but possibly biased. Nonparametric methods which do not
require the distributional assumption are robust and efficient (Helsel, 2005). Several popular
methods, such as Mann-Kendall, the seasonal Kendall test, and multiple regression methods,
are provided to detect and assess changes of various water quality parameters (Helsel,
1992). Meanwhile, nonlinear trends, serial dependence, covariate effects, and irregular
measurement patterns need to be considered (Abaurrea et al., 2011; Morton & Henderson,
2008). Computational implementation using R for linear regression models is introduced.
Examples using a real dataset are given to illustrate some very useful R functions.
7. Acknowledgments
Dr. Liya Fu is a postdoc fellow whose research was supported by the Centre for Applications
in Natural Resource Mathematics (CARM), School of Mathematics and Physics, the University
of Queensland, Australia.
8. References
Abaurrea, J., Asín, J., Cebrián, C. C. & García-Vera, M. A. (2011). Trend analysis of water
quality series based on regression models with correlated errors, Journal of Hydrology,
Vol. 400, 341–352.
Adler, J. (2009). R in a nutshell, O’Reilly Germany.
Brown, R. M., McClelland, N. I., Deininger, R. A. & Tozer, R. G. (1970). A water quality index:
Do we dare? Water and Sewage Works, 117, 339–343.
Brown, B. M. & Wang, Y-G. (2006). Induced smoothing for rank regression with censored
survival times, Statistics in Medicine, 26, 828–836.
Canadian Council of Ministers of the Environment (CCME). (2001). Canadian water quality
guidelines for the protection of aquatic life, CCME water quality Index 1.0,
Technical Report. In: Canadian environmental quality guidelines, 1999. Winnipeg:
Canadian Council of Ministers of the Environment. http://www.ccme.ca/assets/pdf/
wqi_techrprtfctsht_e.pdf.
Cleveland, W. S. (1979). Robust locally weighted regression and smoothing scatterplots,
Journal of the American Statistical Association, 74, 829–836.
Cleveland, W. S., Grosse, E. & Shyu, W. M. (1992). Local regression models, Chapter 8 of
Statistical Models in S eds Chambers and Hastie, Wadsworth & Brooks/Cole.
Chambers, J. M., Cleveland, W. S., Kleiner, B. & Tukey, P. A. (1983). Graphical methods for data
analysis, PWA-Kent Publishing Co., Boston.
166
24 Water Quality Monitoring and Assessment
Will-be-set-by-IN-TECH
Hirsch, R. M., Alexander, R. B. & Smith, R. A. (1991). Selection of methods for the detection
and estimation of trends in water quality, Water Resources Research, Vol. 27, No. 5,
803–813.
Hirsch, R. M., Slack, J. R. & Smith, R. A. (1982). Techniques of trend analysis for monthly water
quality data, Water Resources Research, Vol. 18, 107–121.
Hirsch, R. M. & Slack, J. R. (1984). A nonparametric trend test for seasonal data with serial
dependence, Water Resources Research, Vol. 20, No. 6, 727–732.
Hornung, R. W. & Reed, L. D. (1990). Estimation of average concentration in the presence of
nondetectable values, Applied Occupational and Environmental Hygiene, 5, 46–51.
Horton, R. K. (1965). An index-number system for rating water quality. Journal of Water
Pollution Control Federation, Vol. 37, No. 3, 300–306.
Jin, Z., Lin, D. Y. & Wei, L. J. (2003). Rank-based inference for the accelerated failure time
model, Biometrika, 90, 341–353.
Jin, Z., Lin, D. Y. & Ying, Z. (2006). On least-squares regression with censored data, Biometrika,
93, 147–161.
Jin, Z., Lin, D. Y. & Ying, Z. (2006b). Rank regression analysis of multivariate failure time data
based on marginal linear models, Scandinavian Journal of Statistics, 33, 1–23.
Kannel, P. R., Lee, S., Kanel, S. R. & Khan, S. P. (2007). Application of water quality indices
and dissolved oxygen as indicators for river water classification and urban impact
assessment, Environmental Monitoring Assessment, Vol. 132, 93–110.
Kendall, M. G. (1975). Rank correlation methods, Charles Griffin, London.
Landwehr, J. M. & Deininger, R. A. (1976). A comparison of several water quality indices,
Journal of Water Pollution Control Federation, Vol. 48, No. 5, 954–958.
Lee, L. & Helsel, D. R. (2005). Statistical analysis of water-quality data containing multiple
detection limits: S-language software for regression on order statistics, Computer &
Geosciences, 31, 1241–1248.
Lee, L. & Helsel, D. R. (2007). Statistical analysis of water-quality data containing multiple
detection limits II: S-language software for nonparametric distribution modeling and
hypothesis testing, Computer and Geosciences, 33, 696–704.
Lee, E. W., Wei, L. J. & Ying, Z. (1993). Linear regression analysis for highly stratified failure
time data, Journal of the American Statistical Association, 88, 557–565.
Lettenmaier, D. P. (1988). Multivariate nonparametric tests for trend in water quality, American
Water Resources Association, Vol. 24, No. 3, 505–512.
Lubin, J. H., Colt, J. S., Camann, D., Davis, S., Cerhan, J. R., Severson, R. K., Bernstein, L. &
Hartge, P. (2004). Epidemiologic evaluation of measurement data in the presence of
detection limits, Environmental Health Perspectives, 112, 1691–1696.
Mann, H. B. (1945). Non-parametric tests against trend, Econometrica, 13, 245–259.
Alternative for handling detection limits data in impact assessments, Ground Water Monitor
Remediation, 4, 42–44.
McClelland, N. I. (1974). Water quality index application in the Kansas river basin. U.S.
Environmental Protection Agency Region 7, Kansas City, Missouri.
McGill, R., Tukey, J. W. & Larsen, W. A. (1978). Variations of box plots, The American Statistician,
Vol. 32, No.1, 12–16.
Morton, R. & Henderson, B. L. (2008). Estimation of nonlinear trends in water quality: An
improved approach using generalized additive models, Water Resourse Research, Vol.
44, W07420, doi:10.1029/2007WR006191.
168
26 Water Quality Monitoring and Assessment
Will-be-set-by-IN-TECH
Prati, L., Pavenello, R. & Pesarin, F. (1971). Assessment of surface water quality by single index
of pollution, Water Research, 5, 741–751.
Pesce, S. F. & Wunderlin, D. A. (2000). Use of water quality indices to verify the impact of
Cordoba city (Argentina) on Suquýa river, Water Research, 34, 2915–2926.
Qian, Y., Migliaccion, K. W., Wang, Y. S. & Li, Y. C. (2007). Surface water quality evaluation
using multivariate methods and a new water quality index in the Indian River
Lagoon, Florida. Water Recourses Research, 43, 1–10.
Raican, S. M., Wang, Y-G., Harch, B. (2011). Water quality assessments for reservoirs using
spatio-temporal data from balanced/unbalanced monitoring designs. submitted
Sanchez, E., Colmenarejo, M. F., Vicente, J., Rubio, A., Garcia, M. G., Travieso, L. & Borja,
R. (2007). Use of the water quality index and dissolved oxygen deficit as simple
indicators of watersheds pollution, Ecological Indicators, 7, 315–328.
Shumway, R. H., Azari, R. S. & Kayhanian, M. (2002). Statistical approaches to estimating
mean water quality concentrations with detection limits, Environmental Science and
Technology, 36, 3345–3353.
Tobin, J. (1958). Estimation of relationships for limited dependent variables, Econometrica, Vol.
26, No. 1, 24–36.
Tukey, J. W. (1977). Exploratory data analysis, Addison-Wesley Pub., Reading, MA.
Van Belle, G. & Hughes, J. P. (1984). Nonparametric tests for trend in water quality, Water
Resources Research, Vol. 20, No. 1, 127–136.
Venables, W. N. & Ripley, B. D. (2002). Modern applied statistics with S, Springer.
Wei, L. J. (1992). The accelerated failure time model: a useful alternative to the Cox regression
model in survival analysis, Statistics in Medicine, Vol. 11, 1871–1879.
Yu, Y.-S., Zou, S. & Whittemore, D. (1993). Non-parametric trend analysis of water quality
data of rivers in Kansas, Journal of Hydrology, Vol. 150, 61–80.
Zhang, D. H., Fan, C. P., Zhang, J. & Zhang, C-H. (2009). Nonparametric methods for
measurements below detection limits, Statistics in Medicine, 28, 700–715.
Zandbergen, P. A. & Hall, K. J. (1998). Analysis of the British Columbia water quality index for
watershed managers: a case study of two small watershelds. Water Quality Research
Journal of Canada, 33, 519–549.