Detecting and Estimating Trends of Water Quality Parameters

Water quality variables frequently exhibit variability in time. This variability may be cyclical with the seasons, steadily (a trend), abruptly (a step-change) or some other established variation over time. It may affect the mean, median, variance, autocorrelation or almost any other aspect of the data. Detection of temporal trends is one of the most important objectives of environmental monitoring. Trend analysis indicates whether pollution concentrations are increasing or decreasing over time. In addition, an estimate of the trend’s magnitude can help to determine whether a statistically significant trend is of practical concern. Noise in the observed data adds uncertainty to detect possibly trends and means that statistical methods are necessary to have accurate detection. The detection and estimation of trends is also complicated by problems associated with characteristics of pollution data. These characteristics are a possible presence of seasonality, skewness, serial correlation, nonnormal data, "less-than" (censored) values, outliers and missing values (Hirsch et al., 1982; Hirsch & Slack, 1984), therefore special statistical tests have been developed to deal with these possibilities.


Introduction
Water quality variables frequently exhibit variability in time. This variability may be cyclical with the seasons, steadily (a trend), abruptly (a step-change) or some other established variation over time. It may affect the mean, median, variance, autocorrelation or almost any other aspect of the data. Detection of temporal trends is one of the most important objectives of environmental monitoring. Trend analysis indicates whether pollution concentrations are increasing or decreasing over time. In addition, an estimate of the trend's magnitude can help to determine whether a statistically significant trend is of practical concern. Noise in the observed data adds uncertainty to detect possibly trends and means that statistical methods are necessary to have accurate detection. The detection and estimation of trends is also complicated by problems associated with characteristics of pollution data. These characteristics are a possible presence of seasonality, skewness, serial correlation, nonnormal data, "less-than" (censored) values, outliers and missing values (Hirsch et al., 1982;Hirsch & Slack, 1984), therefore special statistical tests have been developed to deal with these possibilities.
Many different statistical approaches are currently available for detecting and estimating trends that may be present in water quality variables of interest. These range from simple correlation and regression analyses, time-series analyses, and methods based on nonparametric statistics. Many are complex and too advanced for a basic water quality monitoring programme. Also useful for the detection of trends there are a variety of graphical techniques. For a detailed description of such methods readers may refer, for example, to texts such as Hirsch et al., 1982;Lettenmaier et al., 1982;Hirsch & Slack, 1984;van Belle & Hughes, 1984;Helsel, 1987;Lettenmaier, 1988;Hirsch et al., 1991;McLeod et al., 1991;Esterby, 1993Esterby, , 1996Reckhow et al., 1993;Kundzewicz & Robson (eds), 2000;Hess et al., 2001;Kundzewicz & Robson, 2004;Hesel & Frans, 2006;Visser et al., 2009. Several trend tests have also been described in statistical textbooks (e.g. Gilbert, 1987;Helsel & Hirsch, 1992;Chatfield, 2003;McBride, 2005). Readers who are interested in more advanced methods can refer to recently published book containing the practical application of modern statistical approaches to the analysis of trends in real environmental studies (Chandler & Scott, 2011).
This chapter is focused on presenting commonly used, basic methods for detecting monotonic increasing or decreasing trends in water quality variables, which may be www.intechopen.com useful for routine analysis of trends in environmental monitoring. It provides an overview of some of the main statistical concepts and terminology required for the statistical testing of trend and summarizes and examines some of the major issues and choices involved in detecting and estimating the magnitude of temporal trends in measures of water quality. Presented methods are rather simple and can be easily implemented using various commercial or open-source statistical software packages. As an example the trend analysis of some water quality parameters of the lower Odra River at the monitoring site in Police was performed.

Statistical methods for testing and estimating trends
Trend analysis can be defined as the use of an empirical approach to quantify and explain changes in a system over a period of time (Chandler & Scott, 2011). The purpose of trend testing is to determine if the values of a random variable generally increase (or decrease) over some period of time in statistical terms (Helsel & Hirsch, 1992).
Generally parametric (distribution-dependent) or non-parametric (distribution-free) statistical tests can be used to decide whether there is a statistically significant trend. A test is said to be parametric if the change evaluated by the test can be specified in terms of one or more parameters. Linear regression is an example of a parametric test. Parametric testing procedures are widely used in classical statistics. In parametric testing, it is necessary to assume an underlying distribution for the data (often the normal distribution), and to make assumptions that data observations are independent of one another. If parametric techniques are to be used, it may be necessary to (a) transform data so that its distribution is nearly normal and (b) restrict analyses to annual series, for which independence assumptions are acceptable, rather than using the more detailed monthly, daily or hourly data (Helsel & Hirsch, 1992). Statistical tests designed for normal distributions are very sensitive to outliers and difficult to apply to water-quality records with large numbers of "less-than" values (Schertz et al., 1991). In non-parametric and distribution-free methods, fewer assumptions about the data need to be made (Kundzewicz & Robson, 2004). With such methods it is not necessary to assume a distribution. However, many of these methods still rely on assumptions of independence. They are robust towards missing values, values reported as "below the detection limit" and seasonal effects (Gilbert, 1987). Statistics based on the ranks of observations are one example of such statistics and these play a central role in many non-parametric approaches.
The success of a statistical trend analysis largely depends on selecting the right statistical tools considering various aspects of the available data: whether the data are normally distributed or can be described by an alternative distribution function, whether the data contain seasonality, whether the trend is monotonic or abrupt, and whether the trends are expected to be univariate or multivariate (Visser et al., 2009). The main stages of trend analysis are (Kundzewicz & Robson, 2000) • Obtaining and preparing a suitable dataset • Exploratory analysis of the data • Application of statistical tests • Interpretation of the results www.intechopen.com

Obtaining a suitable dataset
There are many important aspects that may need to be considered when obtaining and preparing data. These include (Kundzewicz & Robson, 2000) • Data should be quality controlled before commencing an analysis of change (e.g. via outlier detection).
• Data series should be as long as possible. Short data series can be strongly affected by seasonal variability which can give misleading results. For investigation of quality change, a minimum of 5 years of monthly data for monotonic trend analysis is suggested (Lettenmaier et al., 1982) • Missing values and gaps in a data series make analysis harder and raise questions of data quality. Gaps in the data may have been filled, and the assumptions used in filling the data will invariably affect the results (e.g. infill techniques by use of historical values under assumption of stationarity, or interpolation based on values of neighbouring points in time and space). Many of the methods presented in this chapter can still be applied to incomplete data series provided that the gaps are not too extensive and that they occur randomly. • Frequency of data. Hourly, daily, monthly and annual data series are commonplace. In a few cases, the data may be irregular. Very frequent data contains more information but can also be harder to analyse both computationally and because more restrictive assumptions must be made.

•
Use of summary measures. It is often appropriate to analyze time series that have been derived from the raw data. For example, it may be sensible to calculate annual means or medians, or to derive annual maximum values. • Use of transformation. Water quality data is often highly skewed and non-normal. In such cases, data analysis can sometimes be assisted if the data is first transformed.

Exploratory data analysis
Examination of the time series is very important before performing and interpreting the statistical calculations. Exploratory data analysis (EDA) is a very powerful graphical technique that is a key component of any data analysis (Kundzewicz & Robson, 2004;Chandler & Scott, 2011). EDA is an advanced visual examination of the data. It involves using graphs to explore, understand and present data, and is an essential component of any statistical analysis. The first use of EDA is usually to examine the raw data in order to identify such features as data problems (outliers, gaps in the record, etc.); temporal patterns (e.g. trend or step-change, seasonality); and regional and spatial patterns. Exploratory data analysis also plays an important role in checking out test assumptions such as independence, or statistical distribution of data values. Finally, EDA is invaluable when it comes to interpreting and presenting the results of a statistical analysis, e.g. for examining residuals, trend gradients and significance levels. A well-conducted EDA is such a powerful tool that it can sometimes eliminate the need for a formal statistical analysis. Alongside EDA, statistical tests become a way of confirming whether an observed pattern is significant. (Kundzewicz & Robson, 2004).
Common types of graph that can be useful for water quality data series include histograms, normal probability and quantile plots, time series plots, correlograms, scatter plots and www.intechopen.com smoothing curves. There are also other plot types, such as box plots or cumulative sum (CUSUM) charts. Use of these graphs should allow identification of the most important features of the data. In particular, they enable visual assessment of any trend or step-change -and can indicate how great trend is relative to overall variation.
Time series plots. The obvious starting point in a trend analysis is usually a plot of the observations against time. Time series plots are designed to illustrate trends with respect to time, together with any seasonality effects. When plotting time series graphs, the data should generally be displayed as either (i) individual points connected with lines if there are up to about 100 values, (ii) connected lines, if there are many values, or (iii) unconnected points if the data is irregular. If there are missing values in an otherwise regular series then the line should be broken at these points. It is sometimes necessary to plot lines through irregular data when there are very many values. To produce a time series plot that best displays the features of the data it may be necessary to plot the data on more than one scale or to transform the data. For water quality data the most common transformation is to take logarithms of the data. If the data series is very long, the display may be improved by spreading the data series over several plots, or by plotting summary statistics (Kundzewicz & Robson, 2000). Interpretation of the time series plot is often aided by adding a smoothing curve (and sometimes a regression line) to follow the general trend in the data. Smoothing methods include methods such running means, or locally weighted regression (lowess) . Care must be taken that the degree of smoothing is appropriate for the data, e.g. if seasonality is present the smoothing window must cover a number of years. When data from several sites or variables are available, it can be informative to examine the series together, e.g. presenting data for several sites within a region on a single page.
Boxplots (box and whisker plots). Time series plots are conceptually simple, but they do not fulfill all of the previously described aims of an exploratory analysis. The boxplot is an alternative graphical technique that remedies some of these deficiencies (Chandler & Scott, 2011). Boxplots are designed to facilitate comparisons between the distributions of observations falling in different groups -for example different months of the year, different years or different spatial locations. For each group of observations, the 'box' extends from the first to the third quartile of the data; the height of the box thus represents the interquartile range (IQR). The median is indicated in each box by a horizontal line. The whiskers extend in each direction to the most extreme data point that is at most 1.5 IQRs away from the box; observations more extreme than this are marked individually. The idea is that the whiskers represent the main body of each distribution and observations falling beyond the whiskers are possible outliers. Symmetric data would case the median to lie in the middle of the rectangle and the lengths of the upper and lower whiskers would be about the same. In summary, by allowing a visual comparison of entire distributions, boxplots provide a powerful supplement to time series plots in an exploratory analysis. They are particularly useful for assessing changes in the variability and shape of distributions and for identifying possible outliers.  (Letenmaier, 1976;Guilbot et al., 1986;Chassande, 1989, as cited in Cun & Vilagines, 1997).
Histograms, normal probability and quantile plots. These plots can be used to examine the distribution of raw data or residuals (Kundzewicz & Robson, 2004). Histograms show the general shape of the distribution. Quantile plots simply plot the data values against their rank, or against the equivalent quantiles from a reference distribution e.g. the normal. If the quantile plot gives a straight line then the data can be assumed to come from the required distribution. If it deviates significantly from a straight line then this indicates departure from the assumed distribution and indicates which part of the data deviates from this distribution. The normal probability plot is a graphical technique for assessing whether or not a data set is approximately normally distributed. The data are plotted against a theoretical normal distribution in such a way that the points should form an approximate straight line. Departures from this straight line indicate departures from normality.

Autocorrelation plots.
Most tests for detecting change assume independence of the sample values. Independence means that knowing the current value of a variable provides no information about what the next value will be. This clearly does not hold for time series data, which are usually correlated due to being observed frequently or seasonally. One way to quantify the extent of the correlation (dependence) is to calculate the autocorrelation function ACF ( see e.g. Kendall & Ord, 1990). Autocorrelation is a measure of the correlation of a variable with itself, but with the time shifted. For example, a lag 1 autocorrelation for a daily series is the correlation between the series and the same series but moved 1 day. The lag 2 autocorrelation is the correlation with a time difference of 2. The autocorrelation plot shows the correlations at a series of lags. If autocorrelation is present at one or more lags then the data is not independent. To aid interpretation of a correlogram, it is common to add horizontal lines showing the magnitude of coefficients that should be considered 'significantly' different from zero. These lines define approximate 95% confidence limits for individual coefficients, under the assumption that the observations are an uncorrelated sequence of values drawn from probability distributions with a common mean and variance (Chatfield, 2003).
For further details of exploratory data analysis the user should refer to Kundzewicz & Robson, 2000. Excellent presentations of the general principles of EDA can also be found in Cleveland, 1994 andTufte, 1983.

Basics of statistical testing for trend
The main stages in statistical testing for trend are (Kundzewicz&Robson (eds), 2000): • Decide what type of series/variable to test depending on the issues of interest (e.g. monthly averages, annual maxima, deseasonalized data, etc.).

•
Decide what types of change are of interest (gradual trend or step-change).

•
Check out data assumptions (e.g. use exploratory data analysis, or a formal test).

•
Select a statistical test (more than one is good practice). • Evaluate significance levels.

•
Investigate and interpret results.
In order to carry out a statistical test, it is necessary to define the null and alternative hypotheses; these are statements that describe what the test is investigating (Helsel & Hirsch, 1992). For example, to test for trend in the mean of a series the null hypothesis (H 0 ) would be that there is no change in the mean of a series, and the alternative hypothesis (H 1 ) would be that the mean is either increasing or decreasing over time. In carrying out a statistical test, one starts by assuming that the null hypothesis is true, and then checks whether the observed data are consistent with this hypothesis. The null hypothesis is rejected if the data are not consistent. To compare between the null and alternative hypotheses, a test statistic is selected and then its significance is evaluated, based on the available evidence. The test statistic is simply a numerical value that is calculated from the data series that is being tested. A simple example of a test statistic is the linear regression coefficient; this can be used to test for a trend in the mean. If there is no trend (the null hypothesis) then the regression coefficient should have a value near to zero. If there is a large trend in the mean (the alternative hypothesis), then the value of the regression coefficient would be very different from zero, being positive for increasing trend and negative for decreasing trend.
Two types of errors can result from a hypothesis test.
• Type I error. A Type I error occurs when the researcher rejects a null hypothesis when it is true. The probability of committing a Type I error is called the significance level. This probability is also called alpha, and is often denoted by . • Type II error. A Type II error occurs when the researcher fails to reject a null hypothesis that is false. The probability of committing a Type II error is called Beta, and is often denoted by . The probability of not committing a Type II error is called the Power of the test.
The significance level measures whether the test statistic is very different from the range of values that would typically occur under the null hypothesis. It is the probability that a test erroneously detects trend when none is present. Popular levels of significance are 10% (0.1), 5% (0.05), 1% (0.01). Choosing level of significance is an arbitrary task, but for many applications, a level of 5% is chosen. Thus a 5% significance level would be interpreted as strong evidence against the null hypothesis-with a 1 in 20 chance of that conclusion being wrong.
The analysis plan includes decision rules for rejecting the null hypothesis. In practice, statisticians describe these decision rules in two ways -with reference to a P-value or with reference to a region of acceptance.
• P-value. The strength of evidence in support of a null hypothesis is measured by the Pvalue. Suppose the test statistic is equal to S. The P-value is the probability of observing a test statistic as extreme as S, assuming the null hypothesis is true. If the P-value is less than the significance level, we reject the null hypothesis. • Region of acceptance. The region of acceptance is a range of values. If the test statistic falls within the region of acceptance, the null hypothesis is not rejected. The region of acceptance is defined so that the chance of making a Type I error is equal to the significance level. The set of values outside the region of acceptance is called the region of rejection. If the test statistic falls within the region of rejection, the null hypothesis is rejected. In such cases, we say that the hypothesis has been rejected at the level of significance.
These approaches are equivalent. Some statistics texts use the P-value approach; others use the region of acceptance approach.
A test of a statistical hypothesis, where the region of rejection is on only one side of the sampling distribution, is called a one-tailed test. For example, suppose the null hypothesis states that the mean is less than or equal to 10. The alternative hypothesis would be that the mean is greater than 10. The region of rejection would consist of a range of numbers located on the right side of sampling distribution; that is, a set of numbers greater than 10. A test of a statistical hypothesis, where the region of rejection is on both sides of the sampling distribution, is called a two-tailed test. For example, suppose the null hypothesis states that the mean is equal to 10. The alternative hypothesis would be that the mean is less than 10 or greater than 10. The region of rejection would consist of a range of numbers located on both sides of sampling distribution; that is, the region of rejection would consist partly of numbers that were less than 10 and partly of numbers that were greater than 10 (Stat Trek).
When interpreting test results it is necessary to remember that no statistical test is perfect, even if all test assumptions are met. If more than one test has been applied to the data, interpretation of results can be complex. The presence of a single significant test result may only be weak evidence of change-even if this test is highly significant. If more tests are significant then this provides stronger evidence of change, unless they are very similar, in which case multiple significance is not an extra proof of change. It is important to examine the test results alongside graphs of the data, and with as much historical knowledge about the data as possible (Kundzewicz & Robson (eds), 2000).

Selecting an appropriate test
There are many approaches that can be used to detect trends in water quality data. In deciding which approach to take it is necessary to be aware of which test procedures are valid (i.e. the data meets the required test assumptions) and which procedures are most useful (likely to correctly find change when it is present). Type of used statistic (parametric or non-parametric) depends on data characteristics Assumption checking may need to be carried out both prior to and after application of tests. For example, if a trend is detected, then the trend should be estimated and removed from www.intechopen.com the data, and the residuals checked for autocorrelation and for constancy of distribution. Use of visual methods for assumption checking will usually be sufficient, however formal tests described in many standard statistical books are also available for checking some assumptions: tests for normality of data (e.g. Kolmogorov-Smirnov and the Shapiro-Wilk's test of normality) and tests for data independence (e.g. Bartlett's test) If the assumptions made in a statistical test are not fulfilled by the data, then test results can be meaningless, in the sense that the estimates of significance level would be grossly incorrect.
General applicability of tests is listed bellow.
• If data are normally distributed, independent and non-seasonal either parametric or nonparametric tests should be suitable.

•
Traditional parametric test statistics based on normal distribution could not have been used if data is not normally distributed, is seasonal, contains extreme values, contains values less than a detection limit, or irregular sampling frequency.

•
When the assumptions required by parametric statistical tests cannot be met, any of the distribution-free tests are suitable, because they are not particularly sensitive to missing data or outliers, and requires no assumption of normality

Some commonly used tests and test statistics
This section presents a number of standard tests for detection of temporal trends. The tests are described in their standard or basic form.

Linear regression
If plots of data versus time suggest a simple linear increase or decrease over time, a linear regression of the water quality variable Y against time T may be fit to the data (Gilbert, 1987). The test statistic for linear regression is the regression coefficient (slope). This is one of the simplest and most common tests for trend and, in its basic form, assumes that data are roughly normally distributed (i.e., symmetric and unimodal). It can be misleading if seasonal cycles are present, the data are not normally distributed, and/or the data are serially correlated. In general, the normality assumption is less important than the independence assumption, and the proposed procedures give reasonable estimates of the trend even if the normality assumption is violated but the independence assumption holds (PMFine/Reports, 1991). Linear regression may be able to use with transformed data (Helsel & Hirsch, 1991).
The model is formulated as follows Y =a +bT +ε T where a is the intercept, b is the slope and ε T are random errors. T represents the year with the initial year taken as year 1. The errors are assumed to be independent and identically distributed. This assumption is more likely to be satisfied if yearly average is used as the response variable.
The regression coefficients can be estimated using the method of least squares (OLS). Hence, the estimates of the slope and intercept are given by (Montgomery et al., 2001).
where Y is the mean of Y, T is the mean of T The standard error of the slope is The OLS estimations of the slope b and the standard error of the slope can be obtained using statistical computing software.
A t test may be used to test that the true slope is not different from zero.
This test statistic follows a Student distribution with df = n-2 degrees of freedom under the null hypothesis. We conclude that linear trend exist if P-value of t b statistic is less than α. A positive (negative) value of b indicates an upward (downward) linear trend and b is the magnitude of that trend. 100(1-alfa)% two-sided confidence interval for b is b ± t(1-α, df=n-2)SE(b). The strength of the trend can also be reported as a percent change over time by dividing the slope of the regression line by the mean value of the water quality parameter of interest over time.
To determine how much (or how little) of the change in the water quality parameter of interest is correlated with time, or stated another way, to determine the percentage of the variability in the water quality parameter of interest that is explained by the variability in time, we look at the coefficient of determination. The coefficient of determination (denoted by R 2 ) is interpreted as the proportion of the variance in the dependent variable that is predictable from the independent variable. R 2 = 0.10 means that 10 percent of the variance in Y is predictable from X; R 2 =0.87 means that 87 percent is predictable; and so on.
After the model is fit, test for autocorrelation in the residuals using the Durbin-Watson statistic can be performed (Montgomery et al., 2001). The Durbin-Watson test is a test for first-order serial correlation in the residuals of a time series regression. The test statistic is The simple regression model of Equation (1) can be modified to account for seasonality in the observations and/or information from other covariates (Helsel & Hirsch, 1992). If autocorrelation seems to be present, then the regression model can still be used. However, it should be fitted using a method that is more appropriate than ordinary least-squares (see e.g. Zetterqvist, 1991). Some statistical packages provide one or more of these methods as options.

Spearman's rank correlation coefficient
This is a rank-based test for correlation between two variables that can be used to test for a correlation between time and the data series (Gauthier, 2001). It can be used for trend detection but cannot be used for trend estimation.
Spearman's rank correlation coefficient or Spearman's rho, often denoted by the Greek letter ρ (rho) or as r s , is a non-parametric measure of statistical dependence between two variables.
It assesses how well the relationship between two variables can be described using a monotonic function. The sign of the Spearman correlation indicates the direction of association between X (the independent variable) and Y (the dependent variable). If Y tends to increase when X increases, the Spearman correlation coefficient is positive. If Y tends to decrease when X increases, the Spearman correlation coefficient is negative. A Spearman correlation of zero indicates that there is no tendency for Y to either increase or decrease when X increases. The Spearman correlation increases in magnitude as X and Y become closer to being perfect monotone functions of each other. When X and Y are perfectly monotonically related, the Spearman correlation coefficient becomes +1 or -1.
The idea behind the rank correlation coefficient is simple. Each variable is ranked separately from lowest to highest (e.q. 1, 2, 3, etc.) and the difference between ranks of each data pair is calculated. Tied values (equal-valued) are assigned a rank equal to the average of their positions in the ascending order of the values.
where , 1 where d i is the difference between ranks.
For small values of n, the significance level of the r s test statistic can be looked up in special tables (Gilbert, 1987;Helsel & Hirsch, 1992). For samples with more than 20 values a t statistic can be calculated using equation which is distributed approximately as Student's t distribution with n − 2 degrees of freedom (df). Hence if P-value associated with that t statistic is less than α, we reject the null hypothesis and conclude that there is a trend in the data. If r s is positive, we conclude that there is an increasing trend, and if it is negative, we conclude that there is a decreasing trend.
Spearman correlation coefficient can be used to test for detecting trends in time series data with no seasonal effects. If seasonal cycles are present in the data, that test can be used after removing seasonal variation, or by examining data collected in the same month over several years (Gauthier, 2001).

Non-seasonal Mann-Kendall test
The Mann-Kendall test is a nonparametric trend test which has the same power as the Spearman's rho test in detecting monotonic trends (Yue et al., 2002). It is appropriate for data that do not display seasonal variation, or for seasonally corrected data, with negligible autocorrelation.
The non-seasonal Mann-Kendall test (M-K) is applicable in cases when the data values Y i of a time series can be assumed to obey the model where f(T i ) is a continuous monotonic increasing or decreasing function of time and the residuals ε i can be assumed to be from the same distribution with zero mean. It is therefore assumed that the variance of the distribution is constant in time.
The M-K test is based on the statistic S (Gilbert, 1987). When only one datum per time period is taken, each pair of observed values Yi, Yj (i >j) of the random variable is inspected to find out whether Yi >Yj or Yi < Yj. Let the number of the former type of pairs be P, and the number of the latter type of pairs be M. Then S is defined as www.intechopen.com If n is 10 or less, the absolute value of S is compared directly to the theoretical distribution of S derived by Mann and Kendall (Gilbert, 1987). Then Ho is rejected in favor of H 1 if the probability value corresponding to the absolute value of S is less than the a priori specified α significance level of the test. A positive (negative) value of S indicates an upward (downward) trend. For time series time series with 10 or more data points the normal approximation is used. The test procedure is to first compute S using Eq.14 as described before. Then compute the variance of S by the following equations where n is the number of data, p is the number of tied groups in the data set and t j is the number of data points in the jth tied group.
Then S and Var(S) are used to compute the test statistic Z as follows There is a correction for ties (±1 added to the S) when y i = y j (Salas, 1993, as cited in (Gilbert, 1987).
The standardized test statistic Z is approximately normally distributed. A positive (negative) value of Z indicates an upward (downward) trend. To test for the either upward or downward trend (a two-tailed test) at the α level of significance, Ho is rejected if Z > Z (1-α/2) . If the alternative hypothesis is for an upward trend (a one-tailed test), Ho is rejected if Z > Z (1-α) . We reject Ho in favor of the alternative hypothesis of a downward trend if Z is negative and Z > Z (1-α) . Using P-value calculated for Z, Ho is rejected if P < α.
The Kendall's correlation coefficient, a measure of the strength of the correlation, can be calculated as (Kendall, 1975)  When there are multiple observations per time period, there are two ways to proceed (Gilbert, 1987). First, we could apply the Mann-Kendall test to the medians or means calculated for each time period. An alternative approach is to consider the n i ≥ 1 observations at time i (or time period i) as ties in the time index. For this latter case the statistic S is still computed by Eq.14, where n is now the sum of the n j , that is, the total number of observations. The differences between data obtained at the same time are given the score 0 no matter what the data may be, since they are tied in the time index. When there are multiple observations per time period, the variance of S is computed by the following equations, which account for ties in the time index where p and t j are defined following (Eq.15), h is the number of time periods that contain multiple data, and u q is the number of multiple data in the qth time period. Equation 19 reduces to Equation 15 when there is one observation per time.
To estimate the magnitude of an existing trend (as change per unit time) the Sen's nonparametric method may be used (Sen, 1968). Sen's Slope estimator is a nonparametric alternative for estimating a slope. This approach involves computing slopes for all the pairs of time points Q i and then using the median of these slopes as an estimate of the overall slope Q. As such, it is insensitive to outliers and can handle a moderate number of values below the detection limit and missing values.
where Y j and Y i are data values a times (or during time period) j and i, respectively, and where j>i; N is the number of data pairs for which j>i. If there is only one datum in each time period, then N= n(n-1)/2, where n is the number of time periods. If there are multiple observations in one or more time periods then N < n(n-1)/2, where n is now the total number of observations, not time periods, since Eq.20 cannot be computed with two data from the same time period, that is, when j=i. The median of N slope estimates is obtained in the usual way. That is, the N values of Q are ranked from smallest to largest and we compute Trend slope Q is a measure of monotonic change during the selected study period. The trend slopes represent the median rate of change in constituent concentrations or values for the selected period. They assist the user in comparing the magnitudes of trends that represent the same period for stations in a study. A 100(1-alfa)% two-sided confidence interval about the true slope may be obtained by the nonparametric technique (Sen, 1968). This procedure based on the normal distribution is valid for n as small as 10 unless there are many ties. At first we compute where Var(S) is computed from Eq. 15 or 19. The latter equation is used if there are multiple observations per time period. Next M 1 =(N-C α )/2 and M 2 =(N+C α )/2 are computed. The lower and upper limits of the confidence interval Q min and Q max are the M 1 th largest and (M 2 +1) th largest of the N ordered slope estimates Q i , respectively. If M 1 is not a whole number the lower limit is interpolated. Correspondingly, if M 2 is not a whole number the upper limit is interpolated (Gilbert, 1987).
This method is very useful in cases where the trend can be assumed to be linear (Salmi et all., 2002). This means that f(T i ) in Equation 13 is equal to where Q is the slope and B is a constant.
To obtain an estimate of B in Equation 23 the n values of differences Y i -QT i are calculated. The median of these values gives an estimate of B. The estimates for the constant B of the 100(1-alfa)% confidence intervals are calculated by a similar procedure.

Regional non-seasonal Mann-Kendall test
When data are collected at several stations within a region, there may be interest in making a general statement about trends. This statement about the presence or absence of monotonic trends will be meaningful if the trends at all the stations are in the same directions -that is, all upward or all downward. Time plots of the data at each station, preferably on the same graph, may indicate when general statements are possible. In many situations an objective testing method will be needed to help make the decision. The following procedure was originally proposed by van Belle and Hughes to test for homogeneity of trends between seasons (van Belle & Hughes, 1984).
To test for homogeneity of trend at multiple stations, chi-square statistic, χ 2 homog can be used To test for trend homogeneity between stations, we can compare the P-value calculated for this chi-square statistic to the significance level. If P < α we reject the Ho of homogenous station trends (trends have significantly different directions at different stations). In that case no regional -wide statements should be made about trend direction. However, a Mann-Kendall test for trend at each station may be used. If P > α then the statistic χ 2 trend 2 Z = is referred to the chi-square distribution with 1 df to test that the (common) trend direction is significantly different from zero. The trend is significant if P value associated with χ 2 trend is less then α.

Seasonal Kendall test
If seasonal cycles are present in the data, tests for trend after removing these cycles from data or are not affected by them should be used. Hirsch, Slack, and Smith proposed the seasonal Kendall (SK) test when seasonality is present (Hirsch et al., 1982). This test is suitable for seasonal data with a moderate level of autocorrelation and may by used even though there are missing, tied or ND values. Furthermore, the validity of the test does not depend on the data being normally distributed. The SK test is a generalization of the Mann-Kendal test. It was proposed for use with 12 seasons (months), but it can be adapted to apply to non-monthly seasonal data (e.g. quarters of the year, weeks). The test consists of computing the Mann-Kendall test statistic S i and its variance, Var(S i ), separately for each month (season) with data collected over years. These seasonal statistics are then summed, and a Z statistic is computed.
K is the number of seasons. The ±1 added to the S K in Eq.28 is a correction factor. This correction is not necessary if there are ten or more data for each season (ni >=10).
To test the null hypothesis, Ho, of no trend versus the alternative hypothesis, H 1 , of either an upward or downward trend (a two-tailed test), Ho is rejected if Z > Z (1-α/2) . If the alternative hypothesis is for an upward trend (a one-tailed test), Ho is rejected if Z > Z (1-α) . We reject Ho in favor of the alternative hypothesis of a downward trend if Z is negative www.intechopen.com and Z > Z (1-α) . Using P-value calculated for Z, Ho is rejected if P < α. To test for homogeneity of trend direction in different seasons at a given station, the procedure developed by van Belle and Hughes can be used (van Belle & Hughes, 1984). This latter test is important, since if the trend is upward in one season and downward in another, the seasonal Kendall test and slope estimator will be misleading. The procedure is to compute where Z i is the Mann-Kendall Z statistic for ith season and χ 2 homog has a chi-square distribution with K-1 degrees of freedom (df).
To test for trend homogeneity between seasons, we can compare the P-value calculated for the χ 2 homog statistic to the significance level. If P<α we reject the Ho of homogenous seasonal trends over time (trends have significantly different directions in different seasons). In that case the seasonal Kendall test and slope are not meaningful, and it is best to compute the Mann-Kendall test and Sen's slope estimator for each individual seasons.
If P > α then the statistic χ 2 trend 2 KZ = is referred to the chi-square distribution with 1 df to test for a common trend in all seasons. This trend is significant if P value for χ 2 trend statistic is less than α.
The seasonal Kendall slope estimator is a generalization of Sen's estimator of slope. It is computed as the median of all slopes between data pairs within the same season. No crossseason slopes contribute to the overall estimate of the Seasonal Kendall trend slope. This slope is the median rate of change of Y over time. A 100(1-alfa)% confidence interval about the slope is obtained in the same manner as in Section 2.5.3.
An assumption with the seasonal Kendall test is that the statistics for the different seasons are independent. When this is not the case an adjustment for serial correlation can be made when calculating Var(S) (Hirsch & Slack, 1984).

Regional seasonal Kendall test
When data are collected at several stations special procedures developed by van Belle and Hughes for M > 1 stations can be used (van Belle & Hughes, 1984). These procedures allow one to test for homogeneity of trend direction at different stations when seasonality is present. The first step is to compute the Mann-Kendall statistic for each season at each station by Eq.14. Next, the appropriate chi-square statistics should be calculated.
The chi-square statistics to test for common trend at different stations when seasonality is present are collected in Table 1.

  -grand mean over all KM stations and seasons
If both χ 2 station and χ 2 season are significant or if χ 2 station-season is significant, then the χ 2 trend test should not be done. The only meaningful trend tests in that case those for individual stationseasons.

Example -Trend analysis of water quality parameters of Odra River
The following paragraphs present the results of applying the statistical methodology outlined in the previous section. As an example trend analysis of water quality parameters of the lower Odra River at the monitoring site in Police was performed. Police is a small city located about 10 km north of Szczecin. Data used in the study were collected monthly by the National Inspection Board for Environmental Protection in Szczecin between 1991 and 2007. pH, dissolved oxygen (DO), biological and chemical oxygen demand (BOD and COD) were investigated in detail. The trend analysis was carried out for annual means and the original (monthly) observations. All statistical analyses were completed using Statistica 9 and Microsoft Excel computer programs at the 0.1 significance level. www.intechopen.com

Trend analysis of annual means
Times series and box plots of annual means of the selected variables are given in Fig. 1 and 2. The boxes show the interquartile interval and the black line in the middle is the median. The front whisker goes from Q1 to the smallest non-outlier in the data set, and the back whisker goes from Q3 to the largest non-outlier; observations more extreme than this are marked individually with a circle (outliers), and the extreme data with an asterisk. For symmetric data the median would lie in the middle of the box, and the lengths of the upper and lower whiskers would be about the same.
A visual inspection of the time series plots (Fig.1) indicates that a downward trend in BOD and COD may exist. The boxplots (Fig.2) show that the data depart from a normal distribution and there are no outliers and extreme values for the variables. Thus, nonparametric tests for trend are likely to be more powerful than conventional parametric techniques in the analysis of data. Time series graphs present no seasonality during the 1991-2007 period which allow to use tests for trend without any seasonal modification.
Firstly, non-parametric Spearman and Mann-Kendall tests for trend were applied and the magnitudes of statistically significant trends were estimated with the corresponding 90% confidence intervals. The trend slopes were also expressed as a percent of the mean water quality concentration by dividing the slope (in original units per year) by the mean and multiplying by 100 (relative trend slopes). Table 2 presents the Spearman and Mann-Kendall test statistics, slope estimates and the conclusions of the tests. The Spearman's rho test provides results almost identical to those obtained for the Mann-Kendall test. Next temporal trends in data were also examined through linear regression analysis. The validity of the regression models are checked by the Durbin-Watson statistic (D-W), which is used for testing the serial correlation of error terms. The results showed insignificant autocorrelation structure of residuals (P-values > 0.1). Normal plots of residuals from linear models (Fig. 3) indicated deviation from normality only at the very extreme ends of the data range, allowing accepting regression analysis as an appropriate tool for detecting trends. Trend analysis results are given in Table 3

Trend analysis of monthly data
The data were first plotted to provide a general overview of possible trends as well as seasonal variations in the data material. Figure 4 shows time series plots of the monthly data. It can be seen that all variables are characterized by strong annual fluctuations. Figure 5 depicts boxplots for individual years. The boxplots show that the data depart from a normal distribution not only in skewness, but also by the number of outliers and the extreme values which motivates the choice of the non-parametric Seasonal Mann-Kendall test for the following trend analysis which is robust against non-normal data and the presence of seasonality and outliers in the data.

Fig. 4. Time series plots of selected variables
To calculate trends, a combination of statistical tests was used. First, the Mann-Kendall statistics for trend over years were computed for each "season". In this study, each of the 12 months of the year was defined as a season. Then the chi-square statistic measuring the overall change in data regardless of direction was computed. This statistic was partitioned into a chi-square due to homogeneity of trend among months and one due to trend. Each chi-square statistic was separately tested to determine significance. For data with a statistically significant monotonic trend the rate of change over time was estimated using a www.intechopen.com seasonal Sen Slope estimator, expressed as a change in units per year. It was computed as the median of all slopes between data pairs within the same season. The significance level of 0.1 was selected for all the trend tests.
Results of the seasonal Kendall trend tests and the Kendall slope estimators are given in tables 5-6. The results indicate significant, negative trends in biological (BOD) and chemical oxygen demand (COD), indicating improved water quality of Odra River. The estimated relative decrease in BOD based on the seasonal Sen Slope (about 4% per year) is twice larger then the relative decrease in COD (about 2% per year). No statistically significant trend in DO was detected. These trend results confirm the main conclusions from previous section.
pH shows trend but in differing directions in different seasons of the year. According to the M-K test (Table 4), the increasing trends are significant in January, March, September and December; however, the decreasing trend is significant in July and August. The increasing trends in winter months seem more significant than the decreasing trends in summer months.

Conclusion
The water quality of water is a subject of ongoing concern. Monitoring is the main tool used to determine the current status of water. An important goal of water quality monitoring is also trend analysis, driven by the desire to know whether the increased effort in waste and land-use management is having a beneficial effect.
This chapter has outlined the key components required for a study of change in water quality data, embracing stages such as preparing a suitable data set, exploratory analysis, application of adequate statistical tests and interpretation of results. The basic statistical tests and estimators described here, along with the use of exploratory data analysis procedures (including some of the types of graphics shown in this chapter), can be of great use in providing insights about water quality trends at a given site and about water quality trends over entire regions.
There is no unique solution to detect trends in water quality across widely differing catchments and monitoring systems. The choice of the method for trend detection and estimation should firstly be made on the basis of the specific goals of the study (only trend detection or also extrapolation), the available resources, and the system under study.
In general, distribution-free methods are recommended because they allow minimal assumptions to be made about the data and are therefore particularly suited to water quality series, which are often neither normally distributed nor independent. These methods are also well suited for analyzing datasets that have outliers, missing or tied data. Another advantage of the non-parametric procedures over parametric alternatives is in many cases, their relative simplicity. One disadvantage of these approaches is the relatively low power (i.e. a low probability of detecting a trend) in cases where the assumptions for a corresponding parametric test are reasonable. Another disadvantage for these procedures is that the some non-parametric tests (such as the Spearman's rho) may only be able to determine whether a statistically significant trend exists (trend detection) and cannot determine the size of the trend. The non-parametric techniques are particularly convenient to use in investigations of multiple data sets. However, in an analysis of an individual record, parametric methods, including use of transformations, can be very suitable. Their use requires careful checking of model fit and residuals. They are often more informative than the non-parametric procedures in more complex applications (Hirsch et al., 1991;Reckhow et al.,1993;Visser, A. et al., 2009).
This chapter showed that statistical methods are useful tools in water quality assessment provides useful information on the possibility of change tendency of the variables in the future. They are believed to assist decision makers in water quality evaluation and also determining priorities in management practices.