Nonparametric test for monotonic trend Within each season based on Kendall's Tau statistic

kendallSeasonalTrendTest(y, ...)

# S3 method for default
kendallSeasonalTrendTest(
  y,
  season,
  year,
  alternative = "two.sided",
  correct = TRUE,
  ci.slope = TRUE,
  conf.level = 0.95,
  independent.obs = TRUE,
  data.name = NULL,
  season.name = NULL,
  year.name = NULL,
  parent.of.data = NULL,
  subset.expression = NULL,
  ...
)

# S3 method for data.frame
kendallSeasonalTrendTest(y, ...)

# S3 method for formula
kendallSeasonalTrendTest(y, data = NULL, subset, na.action = na.pass, ...)

# S3 method for matrix
kendallSeasonalTrendTest(y, ...)

Arguments

y

an object containing data for the trend test. In the default method, the argument y must be numeric vector of observations. When y is a data frame, all columns must be numeric. When y is a matrix, it must be a numeric matrix. In the formula method, y must be a formula of the form y ~ season + year, where y, season, and year specify what variables to use for the these arguments in the call to kendallSeasonalTrendTest.default. Missing (NA), undefined (NaN), and infinite (Inf, -Inf) values are allowed but will be removed.

...

methods passed to or from other methods

season

numeric or character vector or a factor indicating the seasons in which the observations in y were taken. The length of season must equal the length of y.

year

numeric vector indicating the years in which the observations in y were taken. The length of year must equal the length of y.

alternative

character string indicating the kind of alternative hypothesis. The possible values are "two.sided" (tau not equal to 0; the default), "less" (tau less than 0), and "greater" (tau greater than 0).

correct

logical scalar indicating whether to use the correction for continuity in computing the z-statistic that is based on the test statistic S'. The default value is TRUE.

ci.slope

logical scalar indicating whether to compute a confidence interval for the slope. The default value is TRUE.

conf.level

numeric scalar between 0 and 1 indicating the confidence level associated with the confidence interval for the slope. The default value is 0.95.

independent.obs

logical scalar indicating whether to assume the observations in y are seially independent. The default value is TRUE.

data.name

character string indicating the name of the data used for the trend test. The default value is deparse(substitute(y)).

season.name

character string indicating the name of the data used for the season. The default value is deparse(substitute(season)).

year.name

character string indicating the name of the data used for the year. The default value is deparse(substitute(year)).

parent.of.data

character string indicating the source of the data used for the trend test.

subset.expression

character string indicating the expression used to subset the data.

data

specifies an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which kendallTrendTest is called.

subset

specifies an optional vector specifying a subset of observations to be used.

na.action

specifies a function which indicates what should happen when the data contain NAs. The default is na.pass.

Value

A list object with elements for results of the test

Details

Perform a nonparametric test for a monotonic trend within each season based on Kendall's tau statistic, and optionally compute a confidence interval for the slope across all seasons.

References

Hirsch, R.M., Slack, J.R., Smith, R.A. 1982. Techniques of trend analysis for monthly water quality data. Water Resources Research, 18:107-121.

Millard, S. P. 2013. EnvStats: An R Package for Environmental Statistics. Springer, New York.

Examples

kendallSeasonalTrendTest(res ~ month + year, tidfitmean)
#> $statistic
#> Chi-Square (Het)        z (Trend) 
#>         11.86771        -12.56011 
#> 
#> $parameters
#> df 
#> 11 
#> 
#> $p.value
#> Chi-Square (Het)        z (Trend) 
#>     3.736686e-01     3.498302e-36 
#> 
#> $estimate
#>         tau       slope   intercept 
#> -0.41230370 -0.02994651 61.17207956 
#> 
#> $null.value
#> tau tau tau tau tau tau tau tau tau tau tau tau 
#>   0   0   0   0   0   0   0   0   0   0   0   0 
#> 
#> $alternative
#> [1] "The seasonal taus are not all equal\n                                 (Chi-Square Heterogeneity Test)\n                                 At least one seasonal tau != 0\n                                 and all non-zero tau's have the\n                                 same sign (z Trend Test)"
#> 
#> $method
#> [1] "Seasonal Kendall Test for Trend\n                                 (with continuity correction)"
#> 
#> $estimation.method
#> [1] "tau:        Weighted Average of\n                                             Seasonal Estimates\n                                 slope:      Hirsch et al.'s\n                                             Modification of\n                                             Thiel/Sen Estimator\n                                 intercept:  Median of\n                                             Seasonal Estimates"
#> 
#> $sample.size
#>     1     2     3     4     5     6     7     8     9    10    11    12 Total 
#>    38    39    39    39    38    37    39    38    38    38    34    35   452 
#> 
#> $data.name
#>       y  season    year 
#>   "res" "month"  "year" 
#> 
#> $bad.obs
#> [1] 0
#> 
#> $seasonal.S
#>    1    2    3    4    5    6    7    8    9   10   11   12 
#> -395 -363 -411 -351 -299 -327 -227 -232 -121 -219 -207 -273 
#> 
#> $var.seasonal.S
#>        1        2        3        4        5        6        7        8 
#> 6322.333 6833.667 6831.667 6833.667 6327.000 5845.000 6833.667 6326.000 
#>        9       10       11       12 
#> 6327.000 6327.000 4550.333 4958.333 
#> 
#> $seasonal.estimates
#>           tau       slope intercept
#> 1  -0.5618777 -0.04400023  89.65007
#> 2  -0.4898785 -0.04218658  86.05450
#> 3  -0.5546559 -0.05141212 104.72282
#> 4  -0.4736842 -0.03168198  65.35595
#> 5  -0.4253201 -0.02743653  56.98821
#> 6  -0.4909910 -0.02643090  55.17258
#> 7  -0.3063428 -0.02445525  51.67092
#> 8  -0.3300142 -0.01657162  35.93942
#> 9  -0.1721195 -0.01074876  24.42589
#> 10 -0.3115220 -0.02160122  45.76218
#> 11 -0.3689840 -0.03309944  68.44693
#> 12 -0.4588235 -0.03954899  80.94147
#> 
#> $interval
#> $interval$name
#> [1] "Confidence"
#> 
#> $interval$parameter
#> [1] "slope"
#> 
#> $interval$limits
#>         LCL         UCL 
#> -0.03431318 -0.02547727 
#> 
#> $interval$type
#> [1] "two-sided"
#> 
#> $interval$method
#> [1] "Gilbert's Modification of\n                                 Theil/Sen Method"
#> 
#> $interval$conf.level
#> [1] 0.95
#> 
#> $interval$sample.size
#> [1] 8301
#> 
#> 
#> $parent.of.data
#> [1] "tidfitmean"
#>