Skip to contents

runGroups provides comparisons of results, in terms of flow-normalized concentration and flow-normalized flux for any groups of years of years in the water quality record. Comparison could involve the use of the "wall" and/or use of "generalized flow-normalization". These two concepts are described in detail in the vignette: vignette("Enhancements", package = "EGRET").

Usage

runGroups(eList, windowSide, group1firstYear, group1lastYear, group2firstYear,
  group2lastYear, surfaceStart = NA, surfaceEnd = NA, flowBreak = FALSE,
  Q1EndDate = NA, QStartDate = NA, QEndDate = NA, wall = FALSE,
  oldSurface = FALSE, fractMin = 0.75, sample1EndDate = NA,
  sampleStartDate = NA, sampleEndDate = NA, paStart = NA, paLong = NA,
  minNumObs = 100, minNumUncen = 50, windowY = 7, windowQ = 2,
  windowS = 0.5, edgeAdjust = TRUE, verbose = TRUE, saveOutput = FALSE,
  fileName = "temp.txt")

Arguments

eList

named list with at least the Daily, Sample, and INFO dataframes

windowSide

integer. The width of the flow normalization window on each side of the year being estimated. A common value is 11, but no default is specified. If stationary flow normalization is to be used, then windowSide = 0 (this means that flow-normalization period for all years is the same).

group1firstYear

decimal year. Starting year of first group.

group1lastYear

decimal year. Ending year of first group.

group2firstYear

decimal year. Starting year of second group.

group2lastYear

decimal year. Ending year of second group.

surfaceStart

The Date (or character in YYYY-MM-DD) that is the start of the WRTDS model to be estimated and the first of the daily outputs to be generated. Default is NA, which means that the surfaceStart is based on the date of the first sample.

surfaceEnd

The Date (or character in YYYY-MM-DD) that is the end of the WRTDS model to be estimated and the last of the daily outputs to be generated. Default is NA, which means that the surfaceEnd is based on the date of the last sample.

flowBreak

logical. Is there an abrupt break in the discharge record, default is FALSE.

Q1EndDate

The Date (as character in YYYY-MM-DD) which is the last day, just before the flowBreak.

QStartDate

The first Date (as character in YYYY-MM-DD) used in the flow normalization method. Default is NA, which makes the QStartDate become the first Date in eList$Daily.

QEndDate

The last Date (as character in YYYY-MM-DD) used in the flow normalization method. Default is NA, which makes the QEndDate become the last Date in eList$Daily.

wall

logical. Whether there is an abrupt break in the concentration versus discharge relationship due to some major change in pollution control or water management. Default is FALSE.

oldSurface

logical specifying whether to use the original surface, or create a new one. Default is FALSE.

fractMin

numeric specifying the minimum fraction of the observations required to run the weighted regression, default is 0.75. The minimum number will be the maximum of minNumObs and fractMin multiplied by total number of observations.

sample1EndDate

The Date (as character in YYYY-MM-DD) of the last date just before the wall. Default = NA. A date must be specified if wall = TRUE.

sampleStartDate

The Date (as character in YYYY-MM-DD) of the first sample to be used. Default is NA which sets it to the first Date in eList$Sample.

sampleEndDate

The Date (as character in YYYY-MM-DD) of the last sample to be used. Default is NA which sets it to the last Date in eList$Sample.

paStart

numeric integer specifying the starting month for the period of analysis, 1<=paStart<=12. Default is NA, which will use the paStart in the eList$INFO data frame. See also setPA.

paLong

numeric integer specifying the length of the period of analysis, in months, 1<=paLong<=12. Default is NA, which will use the paLong in the eList$INFO data frame. See also setPA.

minNumObs

numeric specifying the miniumum number of observations required to run the weighted regression, default is 100

minNumUncen

numeric specifying the minimum number of uncensored observations to run the weighted regression, default is 50

windowY

numeric specifying the half-window width in the time dimension, in units of years, default is 7

windowQ

numeric specifying the half-window width in the discharge dimension, units are natural log units, default is 2

windowS

numeric specifying the half-window with in the seasonal dimension, in units of years, default is 0.5

edgeAdjust

logical specifying whether to use the modified method for calculating the windows at the edge of the record. The edgeAdjust method tends to reduce curvature near the start and end of record. Default is TRUE.

verbose

logical specifying whether or not to display progress message

saveOutput

logical. If TRUE, a text file will be saved in the working directory of the printout of what is in the console output. Default is FALSE.

fileName

character. Name to save the output file if saveOutput=TRUE.

Value

Dataframe with 7 columns and 2 rows. The first row is about trends in concentration (mg/L), the second column is about trends in flux (million kg/year). The data frame has a number of attributes.

Column NameDescription
Total ChangeThe difference between the results for group2 - group1 (x22 - x11).
CQTCCQTC is the "Concentration v. Q Trend Component." It is the component of total change due to the change in the CQR (Concentration Discharge Relationship). (x20 - x10).
QTCQTC is the "Q Trend Component." It is the component of total change due to the trend in the QD (Discharge Distribution). (x22 - x11 - x20 + x10).
x10The estimated value based on the CQR computed for the years in group1, integrated over the QD for the entire timespan of the Daily data frame (or the period QStartDate and to QEndDate if these are specified).
x11The estimated value based on the CQR for the years in group1, integrated over the QD specified by the user for group1.
x20The estimated value based on the CQR computed for the years in group2, integrated over the QD for the entire period of record.
x22The estimated value based on the CQR for the years in group2, integrated over the QD specified by the user for group2.

Details

When using generalized flow-normalization, it is best to have the Daily data frame extend well beyond the years that are in the Sample data frame. Ideally, the Daily data frame would start windowSide years before the start of the Sample data set, if the data exist to provide for that. Generally that isn't possible for the end of the record because the Sample data may end very close to the present. To the extent that is possible therefore, it is better to include more discharge data after the end of the Sample record. Also note that in the case run in the examples don't do that, because the data set needs to be appropriate for stationary flow normalization as well (and package size considerations make it difficult to include specialized examples).

Examples

eList <- Choptank_eList
# \donttest{

#Option 1:  Use all years for group flow normalization.
groupOut_1 <- runGroups(eList,  windowSide = 0,
                       group1firstYear = 1980, group1lastYear = 1990,
                       group2firstYear = 1995, group2lastYear = 2005)
#> Survival regression (% complete):
#> 0 	1 	2 	3 	4 	5 	6 	7 	8 	9 	10 	
#> 11 	12 	13 	14 	15 	16 	17 	18 	19 	20 	
#> 21 	22 	23 	24 	25 	26 	27 	28 	29 	30 	
#> 31 	32 	33 	34 	35 	36 	37 	38 	39 	40 	
#> 41 	42 	43 	44 	45 	46 	47 	48 	49 	50 	
#> 51 	52 	53 	54 	55 	56 	57 	58 	59 	60 	
#> 61 	62 	63 	64 	65 	66 	67 	68 	69 	70 	
#> 71 	72 	73 	74 	75 	76 	77 	78 	79 	80 	
#> 81 	82 	83 	84 	85 	86 	87 	88 	89 	90 	
#> 91 	92 	93 	94 	95 	96 	97 	98 	99 	
#> Survival regression: Done
#>    Choptank River 
#>    Inorganic nitrogen (nitrate and nitrite)
#>    Water Year 
#> 
#>  Change estimates for
#>  average of 1995  through 2005  minus average of 1980  through 1990 
#> 
#>  For concentration: total change is  0.226 mg/L
#>  expressed as Percent Change is  +22.17 %
#> 
#>  Concentration v. Q Trend Component  +22.17 % 
#>        Q Trend Component              0 %  
#> 
#> 
#>  For flux: total change is  0.022 million kg/year
#>  expressed as Percent Change is  +18.99 % %
#> 
#>  Concentration v. Q Trend Component  +18.99 % 
#>        Q Trend Component             0  
#> 
#>      TotalChange  CQTC QTC  x10  x11  x20  x22
#> Conc       0.226 0.226   0 1.02 1.02 1.24 1.24
#> Flux       0.022 0.022   0 0.12 0.12 0.14 0.14

# Option 2: Use sliding window.
#                In each case it is a 23 year window (23 = 1 + 2 * 11)

groupOut_2 <- runGroups(eList,  windowSide = 11,
                       group1firstYear = 1980, group1lastYear = 1990,
                       group2firstYear = 1995, group2lastYear = 2005)
#> Survival regression (% complete):
#> 0 	1 	2 	3 	4 	5 	6 	7 	8 	9 	10 	
#> 11 	12 	13 	14 	15 	16 	17 	18 	19 	20 	
#> 21 	22 	23 	24 	25 	26 	27 	28 	29 	30 	
#> 31 	32 	33 	34 	35 	36 	37 	38 	39 	40 	
#> 41 	42 	43 	44 	45 	46 	47 	48 	49 	50 	
#> 51 	52 	53 	54 	55 	56 	57 	58 	59 	60 	
#> 61 	62 	63 	64 	65 	66 	67 	68 	69 	70 	
#> 71 	72 	73 	74 	75 	76 	77 	78 	79 	80 	
#> 81 	82 	83 	84 	85 	86 	87 	88 	89 	90 	
#> 91 	92 	93 	94 	95 	96 	97 	98 	99 	
#> Survival regression: Done
#>    Choptank River 
#>    Inorganic nitrogen (nitrate and nitrite)
#>    Water Year 
#> 
#>  Change estimates for
#>  average of 1995  through 2005  minus average of 1980  through 1990 
#> 
#>  For concentration: total change is  0.212 mg/L
#>  expressed as Percent Change is  +20.61 %
#> 
#>  Concentration v. Q Trend Component  +21.97 % 
#>        Q Trend Component             -1.36 %  
#> 
#> 
#>  For flux: total change is  0.0316 million kg/year
#>  expressed as Percent Change is  +28.68 % %
#> 
#>  Concentration v. Q Trend Component  +19.91 % 
#>        Q Trend Component             8.8  
#> 
#>      TotalChange  CQTC     QTC  x10  x11  x20  x22
#> Conc       0.212 0.226 -0.0140 1.02 1.03 1.24 1.24
#> Flux       0.032 0.022  0.0097 0.12 0.11 0.14 0.14

# Option 3: Flow normalization is based on splitting the flow record at 1990-09-30
#                But in years before the break it uses all flow data from before the break,
#                and years after the break uses all flow data after the break

groupOut_3 <- runGroups(eList,  windowSide = 0,
                       group1firstYear = 1980, group1lastYear = 1990,
                       group2firstYear = 1995, group2lastYear = 2005,
                       flowBreak = TRUE, 
                       Q1EndDate = "1990-09-30")
#> Survival regression (% complete):
#> 0 	1 	2 	3 	4 	5 	6 	7 	8 	9 	10 	
#> 11 	12 	13 	14 	15 	16 	17 	18 	19 	20 	
#> 21 	22 	23 	24 	25 	26 	27 	28 	29 	30 	
#> 31 	32 	33 	34 	35 	36 	37 	38 	39 	40 	
#> 41 	42 	43 	44 	45 	46 	47 	48 	49 	50 	
#> 51 	52 	53 	54 	55 	56 	57 	58 	59 	60 	
#> 61 	62 	63 	64 	65 	66 	67 	68 	69 	70 	
#> 71 	72 	73 	74 	75 	76 	77 	78 	79 	80 	
#> 81 	82 	83 	84 	85 	86 	87 	88 	89 	90 	
#> 91 	92 	93 	94 	95 	96 	97 	98 	99 	
#> Survival regression: Done
#>    Choptank River 
#>    Inorganic nitrogen (nitrate and nitrite)
#>    Water Year 
#> 
#>  Change estimates for
#>  average of 1995  through 2005  minus average of 1980  through 1990 
#> 
#>  For concentration: total change is  0.207 mg/L
#>  expressed as Percent Change is  +20.04 %
#> 
#>  Concentration v. Q Trend Component  +21.90 % 
#>        Q Trend Component             -1.86 %  
#> 
#> 
#>  For flux: total change is  0.0371 million kg/year
#>  expressed as Percent Change is  +34.70 % %
#> 
#>  Concentration v. Q Trend Component  +20.56 % 
#>        Q Trend Component             14  
#> 
#>      TotalChange  CQTC    QTC  x10  x11  x20  x22
#> Conc       0.207 0.226 -0.019 1.02 1.03 1.24 1.24
#> Flux       0.037 0.022  0.015 0.12 0.11 0.14 0.14

# Option 4: Flow normalization is based on splitting the flow record at 1990-09-30
#                but before the break uses a 23 year window of years before the break
#                after the break uses a 23 year window of years after the break
groupOut_4 <- runGroups(eList,  windowSide = 11,
                       group1firstYear = 1980, group1lastYear = 1990,
                       group2firstYear = 1995, group2lastYear = 2005,
                       flowBreak = TRUE, 
                       Q1EndDate = "1990-09-30")
#> Survival regression (% complete):
#> 0 	1 	2 	3 	4 	5 	6 	7 	8 	9 	10 	
#> 11 	12 	13 	14 	15 	16 	17 	18 	19 	20 	
#> 21 	22 	23 	24 	25 	26 	27 	28 	29 	30 	
#> 31 	32 	33 	34 	35 	36 	37 	38 	39 	40 	
#> 41 	42 	43 	44 	45 	46 	47 	48 	49 	50 	
#> 51 	52 	53 	54 	55 	56 	57 	58 	59 	60 	
#> 61 	62 	63 	64 	65 	66 	67 	68 	69 	70 	
#> 71 	72 	73 	74 	75 	76 	77 	78 	79 	80 	
#> 81 	82 	83 	84 	85 	86 	87 	88 	89 	90 	
#> 91 	92 	93 	94 	95 	96 	97 	98 	99 	
#> Survival regression: Done
#>    Choptank River 
#>    Inorganic nitrogen (nitrate and nitrite)
#>    Water Year 
#> 
#>  Change estimates for
#>  average of 1995  through 2005  minus average of 1980  through 1990 
#> 
#>  For concentration: total change is  0.207 mg/L
#>  expressed as Percent Change is  +20.04 %
#> 
#>  Concentration v. Q Trend Component  +21.90 % 
#>        Q Trend Component             -1.86 %  
#> 
#> 
#>  For flux: total change is  0.0371 million kg/year
#>  expressed as Percent Change is  +34.70 % %
#> 
#>  Concentration v. Q Trend Component  +20.56 % 
#>        Q Trend Component             14  
#> 
#>      TotalChange  CQTC    QTC  x10  x11  x20  x22
#> Conc       0.207 0.226 -0.019 1.02 1.03 1.24 1.24
#> Flux       0.037 0.022  0.015 0.12 0.11 0.14 0.14

# }