DOI-USGS / EGRET

An R-package for the analysis of long-term changes in water quality and streamflow, including the water-quality method Weighted Regressions on Time, Discharge, and Season (WRTDS). https://doi-usgs.github.io/EGRET/

Home Page:http://doi-usgs.github.io/EGRET/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Need to change help page for runGroups

rmhirsch49 opened this issue · comments

Laura: I've pasted in an exchange I just had with Casey Lee about runGroups. It looks to me like our documentation is wrong. The arguments like group1FirstYear... can be any real numbers (not integers) and they are DecYear values that bound the DecYear values of each of the water years that are to be a part of that group. I'm not totally sure how this might work when the period of analysis is other than water year, such as calendar year or some season.

Thanks.

Bob


Hi Bob, I have a question regarding the runGroups function in the new WRTDS. For the sites draining to the Gulf we were interested in comparing a group of years (the 1980-96 baseline) to the most recent water year (2018 only). However when I specify the same year for the start and end year for period two, I get NA values for all the trend results. Since we compare year pairs in the typical trend analysis, it seemed to me like it would be feasible to compare a group of years to a single year, but before messing around with the code underlying the function, I thought I'd check with you first to make sure this was a good idea.

Thanks, Casey

my response*
Casey: good news. The problem is not something that requires any sort of re-coding. The problem is that our help page didn't get it quite right. I've looked at the code and tried an example with another data set and I think I know the solution. Let me try to state very carefully what I think it is you want to determine and then show you how to get it.

I assume that you are looking for results on a water year basis. So the two groups are water years 1980 - 1996 (inclusive) and water year 2018. For this two work you need to specify this.

group1FirstYear = 1980.0
group1LastYear = 1997.0
group2FirstYear = 2018.0
group2LastYear = 2019.0

Here's what is actually going on. For each year of results it computes a DecYear value for the water year. So, for example for WY 1980 that is about 1980.25 (approximately). That value is the average DecYear value for all the days in that water year. The DecYear value for water year 1996 is about 1996.25. Now, it takes group1FirstYear and group1Last year and finds all the water years that lie between those two dates. Those would be water years 1986 through 1996 (because WY 1996 is the last water year that has its mean DecYear value being <= 1997.0. For the group 2 we want only the water year that has a mean DecYear value between 2018.0 and 2019.0.

You can check to make sure this is working right if you do runGroups this way and then do
seriesOut <- runSeries(eList, windowSide = whatever you are using)
tableResults(seriesOut)

this tableResults function should print a table. You can read off the FNFlux value for water year 2018 and then manually compute an average FNFlux for all the water years 1980 - 1996. Subtract the second number from the first you should get the change in FNFlux reported by runGroups.

If you may need to also do this for some season or for calendar year, let me know. We may need to do a little more thinking and testing to make sure we have that right.

I'm glad you brought this up because we need to fix the documentation.

Bob