Skip to contents

Test for period of record and user-specified ranges. The default trends are calculated for 10 year and the full period of record.

Usage

trend_test(
  gw_level_dv,
  gwl_data,
  n_years = 10,
  parameter_cd = NA,
  date_col = NA,
  value_col = NA,
  approved_col = NA,
  stat_cd = NA,
  pctComplete = 0.5,
  days_required_per_month = 14,
  POR_trend = TRUE
)

Arguments

gw_level_dv

daily groundwater level data frame. Often obtained from from readNWISdv

gwl_data

data frame returned from dataRetrieval::readNWISgwl, or data frame with mandatory columns lev_dt (representing date), lev_age_cd (representing approval code), and a column representing the measured value (either lev_va, sl_lev_va, or value).

n_years

integer. This is the number of years to calculate the trend on. Default is 10. This can be a vector of years.

parameter_cd

If data in gw_level_dv comes from NWIS, the parameter_cd can be used to define the value_col. If the data doesn't come directly from NWIS services, this can be set to NA,and this argument will be ignored.

date_col

the heading of the date column. The default is NA, which the code will try to get the column name automatically.

value_col

name of value column. The default is NA, which the code will try to get the column name automatically.

approved_col

name of column to get provisional/approved status.

stat_cd

If data in gw_level_dv comes from NWIS, the stat_cd can be used to help define the value_col.

pctComplete

number percentage complete. This is a fraction that represents the amount of data that must be included overall in order to calculate a trend. The default is 0.5, which means if gaps in the data span more than 50 total record, a trend will not be calculated.

days_required_per_month

integer. Number of days required per month to include in the trend test. Default is 14.

POR_trend

a logical indicating whether to include a trend test for the full period of record. Default is TRUE.

Value

a data frame of test results from 5 and 20 year Kendall Seasonal Trend test

Details

For data that is at least on a daily interval, the rkt function is used. For periodic data, the kendallTrendTest is used.

Examples


# site <- "263819081585801"
# gw_level_data <- dataRetrieval::readNWISgwl(site)

# Using package example data:
gwl_data <- L2701_example_data$Discrete
                        
gw_level_dv <- L2701_example_data$Daily

trend_test(gw_level_dv,
           gwl_data,
           parameter_cd = "62610")
#>               test        tau pValue      slope  intercept trend
#> 1    10-year trend  0.6144578      0  1.4755392 -2998.4482    Up
#> 2 Period of record -0.3191964      0 -0.2836721   545.4421  Down
           
trend_test(gw_level_dv,
           gwl_data,
           POR_trend = FALSE,
           parameter_cd = "62610")
#>            test       tau pValue    slope intercept trend
#> 1 10-year trend 0.6144578      0 1.475539 -2998.448    Up
           
trend_test(gw_level_dv,
           gwl_data,
           parameter_cd = "62610",
           n_years = 5)
#>               test         tau    pValue      slope intercept           trend
#> 1     5-year trend -0.01333333 0.9514722         NA        NA Not significant
#> 2 Period of record -0.31919643 0.0000000 -0.2836721  545.4421            Down
           
trend_test(gw_level_dv,
           gwl_data,
           parameter_cd = "62610",
           n_years = c(5, 10, 20))
#>               test         tau       pValue      slope  intercept
#> 1     5-year trend -0.01333333 9.514722e-01         NA         NA
#> 2    10-year trend  0.61445783 0.000000e+00  1.4755392 -2998.4482
#> 3    20-year trend  0.34461806 1.807443e-13  0.6532362 -1340.4724
#> 4 Period of record -0.31919643 0.000000e+00 -0.2836721   545.4421
#>             trend
#> 1 Not significant
#> 2              Up
#> 3              Up
#> 4            Down

# Only periodic data:
trend_test(NULL,
           gwl_data,
           parameter_cd = "62610")
#>               test        tau       pValue      slope  intercept trend
#> 1    10-year trend  0.5182648 9.079091e-11  1.5966253 -3243.1985    Up
#> 2 Period of record -0.1628813 1.078165e-05 -0.2200138   414.9972  Down