trend_test: Trend Test

View source: R/statistics.R

trend_testR Documentation

Trend Test

Description

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.

Details

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

Value

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

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")
           
trend_test(gw_level_dv,
           gwl_data,
           POR_trend = FALSE,
           parameter_cd = "62610")
           
trend_test(gw_level_dv,
           gwl_data,
           parameter_cd = "62610",
           n_years = 5)
           
trend_test(gw_level_dv,
           gwl_data,
           parameter_cd = "62610",
           n_years = c(5, 10, 20))

# Only periodic data:
trend_test(NULL,
           gwl_data,
           parameter_cd = "62610")
           

USGS-R/HASP documentation built on July 28, 2024, 7:53 a.m.