Skip to content

Commit

Permalink
Merge pull request #88 from ldecicco-USGS/master
Browse files Browse the repository at this point in the history
randomCensored
  • Loading branch information
ldecicco-USGS authored Jun 21, 2016
2 parents cac8a17 + d0cd64c commit 7002524
Show file tree
Hide file tree
Showing 30 changed files with 254 additions and 194 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: EGRET
Type: Package
Title: Exploration and Graphics for RivEr Trends (EGRET)
Version: 2.5.2
Version: 2.5.3
Authors@R: c( person("Robert", "Hirsch", role = c("aut"),
email = "rhirsch@usgs.gov"),
person("Laura", "DeCicco", role = c("aut","cre"),
Expand All @@ -10,7 +10,7 @@ Description: Statistics and graphics for streamflow history,
water quality trends, and the statistical modeling algorithm: Weighted
Regressions on Time, Discharge, and Season (WRTDS).
License: CC0
Date: 2016-03-07
Date: 2016-06-21
Depends:
R (>= 3.0)
Imports:
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
EGRET 2.5.3
===========
* Argument for randomized censored values names randomCensored

EGRET 2.5.0
===========
* Added an argument to the concentration and residual plotting functions to randomize the censored values for the plots.
Expand Down
5 changes: 0 additions & 5 deletions R/boxConcThree.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ boxConcThree<-function (eList, tinyPlot=FALSE,
paStart <- 10
}

# if(rResid & !all((c("SE","yHat") %in% names(eList$Sample)))){
# message("Pseudo only supported after running modelEstimation, defaulting to rResid=FALSE")
# rResid <- FALSE
# }

localSample <- if(paLong == 12) localSample else selectDays(localSample,paLong,paStart)
localDaily <- if(paLong == 12) localDaily else selectDays(localDaily, paLong,paStart)

Expand Down
6 changes: 3 additions & 3 deletions R/boxResidMonth.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#' @param font.main font to be used for plot main titles
#' @param customPar logical defaults to FALSE. If TRUE, par() should be set by user before calling this function
#' @param las numeric in {0,1,2,3}; the style of axis labels
#' @param rResid logical. Show censored residuals as randomized.
#' @param randomCensored logical. Show censored residuals as randomized.
#' @param \dots arbitrary graphical parameters that will be passed to genericEGRETDotPlot function (see ?par for options)
#' @keywords graphics water-quality statistics
#' @seealso \code{\link[graphics]{boxplot}}
Expand All @@ -36,7 +36,7 @@
#' boxResidMonth(eList)
boxResidMonth<-function(eList, stdResid = FALSE, las=1,
printTitle = TRUE, cex=0.8, cex.axis=1.1, cex.main=1.1,
font.main=2, tinyPlot=FALSE, customPar=FALSE,rResid=FALSE,...) {
font.main=2, tinyPlot=FALSE, customPar=FALSE,randomCensored=FALSE,...) {

localINFO <- getInfo(eList)
localSample <- getSample(eList)
Expand Down Expand Up @@ -65,7 +65,7 @@ boxResidMonth<-function(eList, stdResid = FALSE, las=1,

plotTitle<-if(printTitle) paste(localINFO$shortName,"\n",localINFO$paramShortName,"\nBoxplots of residuals by month") else ""

if(!rResid){
if(!randomCensored){
resid<-log(localSample$ConcAve) - localSample$yHat
} else {
if(!("rResid" %in% names(localSample))){
Expand Down
16 changes: 8 additions & 8 deletions R/fluxBiasEight.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' @param cex.axis magnification to be used for axis annotation relative to the current setting of cex
#' @param col color of points on plot, see ?par 'Color Specification'
#' @param lwd number line width
#' @param rResid logical. Show censored residuals as randomized.
#' @param randomCensored logical. Show censored residuals as randomized.
#' @param \dots arbitrary graphical parameters that will be passed to genericEGRETDotPlot function (see ?par for options)
#' @keywords graphics water-quality statistics
#' @export
Expand All @@ -40,7 +40,7 @@
#' dev.off()
#' }
fluxBiasMulti<-function (eList, qUnit = 2, fluxUnit = 3, moreTitle = "WRTDS",
cex = 0.7, cex.axis = 1.1,cex.main=1.1,rResid=FALSE,
cex = 0.7, cex.axis = 1.1,cex.main=1.1,randomCensored=FALSE,
col="black", lwd=1,...){

localINFO <- getInfo(eList)
Expand Down Expand Up @@ -72,27 +72,27 @@ fluxBiasMulti<-function (eList, qUnit = 2, fluxUnit = 3, moreTitle = "WRTDS",
par(oma = c(0, 10, 4, 10),mfrow=c(4,2))
plotResidPred(eList,
stdResid = FALSE, tinyPlot=TRUE, printTitle = FALSE,cex=cex,
cex.axis = cex.axis, col=col,lwd=lwd,rResid=rResid,...)
cex.axis = cex.axis, col=col,lwd=lwd,randomCensored=randomCensored,...)
plotResidQ(eList,
qUnit, tinyPlot = TRUE, printTitle = FALSE,cex=cex,
cex.axis = cex.axis, col=col,lwd=lwd,rResid=rResid,...)
cex.axis = cex.axis, col=col,lwd=lwd,randomCensored=randomCensored,...)
plotResidTime(eList,
printTitle = FALSE, tinyPlot=TRUE,cex=cex,
cex.axis = cex.axis, col=col,rResid=rResid,lwd=lwd,...)
cex.axis = cex.axis, col=col,randomCensored=randomCensored,lwd=lwd,...)
boxResidMonth(eList,
printTitle = FALSE, tinyPlot=TRUE,cex=cex,
cex.axis = cex.axis,lwd=lwd,rResid=rResid,...)
cex.axis = cex.axis,lwd=lwd,randomCensored=randomCensored,...)
boxConcThree(eList,
localINFO = localINFO, printTitle=FALSE, tinyPlot=TRUE,cex=cex,
cex.axis = cex.axis, lwd=lwd,...)
plotConcPred(eList, printTitle=FALSE,
tinyPlot=TRUE,cex=cex,
cex.axis = cex.axis, col=col,lwd=lwd,rResid = rResid,...)
cex.axis = cex.axis, col=col,lwd=lwd,randomCensored = randomCensored,...)
boxQTwice(eList, printTitle = FALSE, qUnit = qUnit,tinyPlot=TRUE,cex=cex,
cex.axis = cex.axis, lwd=lwd,...)
plotFluxPred(eList,
fluxUnit, tinyPlot = TRUE, printTitle = FALSE,cex=cex,
cex.axis = cex.axis, col=col,lwd=lwd,rResid=rResid,...)
cex.axis = cex.axis, col=col,lwd=lwd,randomCensored=randomCensored,...)
fluxBias <- fluxBiasStat(localSample)
fB <- as.numeric(fluxBias[3])
fB <- format(fB, digits = 3)
Expand Down
8 changes: 4 additions & 4 deletions R/multiPlotDataOverview.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#' @param cex.main magnification to be used for main titles relative to the current setting of cex
#' @param logScaleConc logical if TRUE y in concentration graphs plotted in log axis. Default is TRUE.
#' @param logScaleQ logical if TRUE y in streamflow graphs plotted in log axis. Default is TRUE.
#' @param rResid logical. Show censored values as randomized.
#' @param randomCensored logical. Show censored values as randomized.
#' @keywords graphics water-quality statistics
#' @seealso \code{\link{plotConcQ}}, \code{\link{boxConcMonth}}, \code{\link{plotConcTime}}, \code{\link{boxQTwice}}
#' @export
Expand All @@ -24,7 +24,7 @@
#' # Graphs consisting of Jun-Aug
#' eList <- setPA(eList, paStart=6,paLong=3)
#' multiPlotDataOverview(eList, qUnit=1)
multiPlotDataOverview<-function (eList, qUnit = 2,cex.main=1.2,rResid=FALSE,
multiPlotDataOverview<-function (eList, qUnit = 2,cex.main=1.2,randomCensored=FALSE,
logScaleConc=TRUE, logScaleQ=TRUE){

localINFO <- getInfo(eList)
Expand All @@ -41,9 +41,9 @@ multiPlotDataOverview<-function (eList, qUnit = 2,cex.main=1.2,rResid=FALSE,

par(mfcol=c(2,2),oma=c(0,2.4,4.5,2.4),tcl=0.5)
plotConcQ(eList, qUnit = qUnit, tinyPlot = TRUE, printTitle = FALSE,
rmSciX=TRUE,logScale=logScaleConc,rResid=rResid)
rmSciX=TRUE,logScale=logScaleConc,randomCensored=randomCensored)
boxConcMonth(eList, printTitle = FALSE, tinyPlot=TRUE,logScale=logScaleConc)
plotConcTime(eList, printTitle = FALSE, tinyPlot = TRUE,logScale=logScaleConc,rResid=rResid)
plotConcTime(eList, printTitle = FALSE, tinyPlot = TRUE,logScale=logScaleConc,randomCensored=randomCensored)
boxQTwice(eList, printTitle = FALSE, qUnit = qUnit, tinyPlot=TRUE,logScale=logScaleQ)
title<-paste(localINFO$shortName,"\n",localINFO$paramShortName)

Expand Down
6 changes: 3 additions & 3 deletions R/plotConcPred.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' (for example, adjusting margins with par(mar=c(5,5,5,5))). If customPar FALSE, EGRET chooses the best margins depending on tinyPlot.
#' @param col color of points on plot, see ?par 'Color Specification'
#' @param lwd number line width
#' @param rResid logical. Show censored values as randomized.
#' @param randomCensored logical. Show censored values as randomized.
#' @param \dots arbitrary graphical parameters that will be passed to genericEGRETDotPlot function (see ?par for options)
#' @keywords graphics water-quality statistics
#' @seealso \code{\link{selectDays}}, \code{\link{genericEGRETDotPlot}}
Expand All @@ -33,7 +33,7 @@
#' plotConcPred(eList)
plotConcPred<-function(eList, concMax = NA, logScale=FALSE,
printTitle = TRUE,tinyPlot=FALSE,cex=0.8, cex.axis=1.1,
cex.main=1.1, customPar=FALSE,col="black",lwd=1, rResid = FALSE,...){
cex.main=1.1, customPar=FALSE,col="black",lwd=1, randomCensored = FALSE,...){

localINFO <- getInfo(eList)
localSample <- getSample(eList)
Expand Down Expand Up @@ -80,7 +80,7 @@ plotConcPred<-function(eList, concMax = NA, logScale=FALSE,

xInfo <- generalAxis(x=x, minVal=minXLow, maxVal=concMax, tinyPlot=tinyPlot,logScale=logScale)

if(rResid){
if(randomCensored){
if(!("rObserved" %in% names(localSample))){
eList <- makeAugmentedSample(eList)
localSample <- eList$Sample
Expand Down
6 changes: 3 additions & 3 deletions R/plotConcQ.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#' (for example, adjusting margins with par(mar=c(5,5,5,5))). If customPar FALSE, EGRET chooses the best margins depending on tinyPlot.
#' @param col color of points on plot, see ?par 'Color Specification'
#' @param lwd number line width
#' @param rResid logical. Show censored values as randomized.
#' @param randomCensored logical. Show censored values as randomized.
#' @param \dots arbitrary graphical parameters that will be passed to genericEGRETDotPlot function (see ?par for options)
#' @keywords graphics water-quality statistics
#' @export
Expand All @@ -37,7 +37,7 @@
#' # Graphs consisting of Jun-Aug
#' eList <- setPA(eList, paStart=6,paLong=3)
#' plotConcQ(eList)
plotConcQ<-function(eList, qUnit = 2, tinyPlot = FALSE, logScale=FALSE,rResid=FALSE,
plotConcQ<-function(eList, qUnit = 2, tinyPlot = FALSE, logScale=FALSE,randomCensored=FALSE,
concMax = NA, concMin =NA, printTitle = TRUE, cex=0.8, cex.axis=1.1,cex.main=1.1,
rmSciX=FALSE,rmSciY=FALSE, customPar=FALSE,col="black",lwd=1,...){
localINFO <- getInfo(eList)
Expand Down Expand Up @@ -85,7 +85,7 @@ plotConcQ<-function(eList, qUnit = 2, tinyPlot = FALSE, logScale=FALSE,rResid=FA

xInfo <- generalAxis(x=x, maxVal=NA, minVal=NA, logScale=TRUE, tinyPlot=tinyPlot)

if(!rResid){
if(!randomCensored){
yLow<-localSample$ConcLow
yHigh<-localSample$ConcHigh

Expand Down
8 changes: 4 additions & 4 deletions R/plotConcTime.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#' (for example, adjusting margins with par(mar=c(5,5,5,5))). If customPar FALSE, EGRET chooses the best margins depending on tinyPlot.
#' @param col color of points on plot, see ?par 'Color Specification'
#' @param lwd number line width.
#' @param rResid logical. Show censored values as randomized.
#' @param randomCensored logical. Show censored values as randomized.
#' @param \dots arbitrary functions sent to the generic plotting function. See ?par for details on possible parameters.
#' @keywords graphics water-quality statistics
#' @export
Expand All @@ -42,9 +42,9 @@
#' eList <- setPA(eList, paStart=6,paLong=3)
#' plotConcTime(eList, qUnit = 1, qLower = 100, qUpper = 10000)
#' plotConcTime(eList, logScale=TRUE)
#' plotConcTime(eList, qUnit = 1, qLower = 100, qUpper = 10000, rResid = TRUE)
#' plotConcTime(eList, qUnit = 1, qLower = 100, qUpper = 10000, randomCensored = TRUE)
plotConcTime<-function(eList, qUnit = 2,
qLower = NA, qUpper = NA, rResid=FALSE,
qLower = NA, qUpper = NA, randomCensored=FALSE,
tinyPlot = FALSE, concMax = NA, concMin = NA, printTitle = TRUE,logScale=FALSE,
cex=0.8, cex.axis=1.1,cex.main=1.1, customPar=FALSE,col="black",lwd=1,...){

Expand Down Expand Up @@ -108,7 +108,7 @@ plotConcTime<-function(eList, qUnit = 2,
plotTitle<-if(printTitle) paste(localINFO$shortName,"\n",localINFO$paramShortName,"\n",title3,sep="") else ""


if(!rResid){
if(!randomCensored){
subSample<-subSample[subSample$Q>qLowerBound & subSample$Q<qUpperBound,]
subSample <- if(paLong == 12) subSample else selectDays(subSample, paLong,paStart)
Uncen<-subSample$Uncen
Expand Down
6 changes: 3 additions & 3 deletions R/plotConcTimeDaily.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' (for example, adjusting margins with par(mar=c(5,5,5,5))). If customPar FALSE, EGRET chooses the best margins depending on tinyPlot.
#' @param col color of points on plot, see ?par 'Color Specification'
#' @param lwd number line width
#' @param rResid logical. Show censored values as randomized.
#' @param randomCensored logical. Show censored values as randomized.
#' @param prettyDate logical use 'pretty' limits for date axis if TRUE, or force the startYear/endYear as limits if FALSE
#' @param \dots arbitrary functions sent to the generic plotting function. See ?par for details on possible parameters
#' @keywords graphics water-quality statistics
Expand All @@ -40,7 +40,7 @@
#' eList <- setPA(eList, paStart=6,paLong=3)
#' plotConcTimeDaily(eList)
plotConcTimeDaily<-function(eList, startYear=NA, endYear=NA, tinyPlot = FALSE,
concMax = NA, printTitle = TRUE,cex=0.8, cex.axis=1.1,rResid=FALSE,
concMax = NA, printTitle = TRUE,cex=0.8, cex.axis=1.1,randomCensored=FALSE,
cex.main=1.1, customPar=FALSE,col="black",lwd=1,prettyDate=TRUE,...){

localINFO <- getInfo(eList)
Expand Down Expand Up @@ -79,7 +79,7 @@ plotConcTimeDaily<-function(eList, startYear=NA, endYear=NA, tinyPlot = FALSE,

xInfo <- generalAxis(x=xSample, minVal=startYear, maxVal=endYear, tinyPlot=tinyPlot,padPercent=0,prettyDate=prettyDate)

if(!rResid){
if(!randomCensored){

yLow<-subSample$ConcLow
yHigh<-subSample$ConcHigh
Expand Down
6 changes: 3 additions & 3 deletions R/plotFluxPred.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#' (for example, adjusting margins with par(mar=c(5,5,5,5))). If customPar FALSE, EGRET chooses the best margins depending on tinyPlot.
#' @param col color of points on plot, see ?par 'Color Specification'
#' @param lwd number line width
#' @param rResid logical. Show censored values as randomized.
#' @param randomCensored logical. Show censored values as randomized.
#' @param \dots arbitrary graphical parameters that will be passed to genericEGRETDotPlot function (see ?par for options)
#' @keywords graphics water-quality statistics
#' @export
Expand All @@ -36,7 +36,7 @@
#' plotFluxPred(eList)
plotFluxPred<-function(eList, fluxUnit = 3, fluxMax = NA,
printTitle = TRUE, oneToOneLine=TRUE, customPar=FALSE,col="black", lwd=1,
cex=0.8, cex.axis=1.1,cex.main=1.1,tinyPlot=FALSE,logScale=FALSE,rResid = FALSE,...){
cex=0.8, cex.axis=1.1,cex.main=1.1,tinyPlot=FALSE,logScale=FALSE,randomCensored = FALSE,...){
# this function shows observed versus estimated flux
# estimated flux on the x-axis (these include the bias correction),
# observed flux on y-axis
Expand Down Expand Up @@ -109,7 +109,7 @@ plotFluxPred<-function(eList, fluxUnit = 3, fluxMax = NA,

xInfo <- generalAxis(x=x, minVal=minX, maxVal=NA, logScale=logScale, tinyPlot=tinyPlot,padPercent=5)

if(!rResid){
if(!randomCensored){
yLow<-localSample$ConcLow*localSample$Q*fluxFactor
yHigh<-localSample$ConcHigh*localSample$Q*fluxFactor

Expand Down
6 changes: 3 additions & 3 deletions R/plotResidPred.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#' (for example, adjusting margins with par(mar=c(5,5,5,5))). If customPar FALSE, EGRET chooses the best margins depending on tinyPlot.
#' @param col color of points on plot, see ?par 'Color Specification'
#' @param lwd number line width
#' @param rResid logical. Show censored residuals as randomized.
#' @param randomCensored logical. Show censored residuals as randomized.
#' @param \dots arbitrary graphical parameters that will be passed to genericEGRETDotPlot function (see ?par for options)
#' @keywords water-quality statistics graphics
#' @export
Expand All @@ -36,7 +36,7 @@
#' plotResidPred(eList)
plotResidPred<-function(eList, stdResid = FALSE,
tinyPlot = FALSE, printTitle = TRUE, col="black",lwd=1,
cex=0.8, cex.axis=1.1,cex.main=1.1, customPar=FALSE,rResid=FALSE,...){
cex=0.8, cex.axis=1.1,cex.main=1.1, customPar=FALSE,randomCensored=FALSE,...){
# this function shows residual versus estimated in log space
# estimated log concentration on the x-axis (these are prior to bias correction),
# observed log concentration on y-axis
Expand Down Expand Up @@ -79,7 +79,7 @@ plotResidPred<-function(eList, stdResid = FALSE,

####################

if(!rResid){
if(!randomCensored){

yLow<-log(localSample$ConcLow)-localSample$yHat
yHigh<-log(localSample$ConcHigh)-localSample$yHat
Expand Down
6 changes: 3 additions & 3 deletions R/plotResidQ.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#' (for example, adjusting margins with par(mar=c(5,5,5,5))). If customPar FALSE, EGRET chooses the best margins depending on tinyPlot.
#' @param col color of points on plot, see ?par 'Color Specification'
#' @param lwd number line width
#' @param rResid logical. Show censored residuals as randomized.
#' @param randomCensored logical. Show censored residuals as randomized.
#' @param \dots arbitrary graphical parameters that will be passed to genericEGRETDotPlot function (see ?par for options)
#' @keywords graphics water-quality statistics
#' @export
Expand All @@ -37,7 +37,7 @@
#' plotResidQ(eList)
plotResidQ<-function (eList, qUnit = 2,
tinyPlot = FALSE, stdResid = FALSE, printTitle = TRUE,col="black",lwd=1,
cex=0.8, cex.axis=1.1,cex.main=1.1,rmSciX=FALSE, customPar=FALSE,rResid=FALSE,...){
cex=0.8, cex.axis=1.1,cex.main=1.1,rmSciX=FALSE, customPar=FALSE,randomCensored=FALSE,...){

localINFO <- getInfo(eList)
localSample <- getSample(eList)
Expand Down Expand Up @@ -84,7 +84,7 @@ plotResidQ<-function (eList, qUnit = 2,

xInfo <- generalAxis(x=x, minVal=NA, maxVal=NA, logScale=TRUE, tinyPlot=tinyPlot,padPercent=5)

if(!rResid){
if(!randomCensored){

yLow <- log(localSample$ConcLow) - localSample$yHat
yHigh <- log(localSample$ConcHigh) - localSample$yHat
Expand Down
6 changes: 3 additions & 3 deletions R/plotResidTime.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#' (for example, adjusting margins with par(mar=c(5,5,5,5))). If customPar FALSE, EGRET chooses the best margins depending on tinyPlot.
#' @param col color of points on plot, see ?par 'Color Specification'
#' @param lwd number line width
#' @param rResid logical. Show censored residuals as randomized.
#' @param randomCensored logical. Show censored residuals as randomized.
#' @param \dots arbitrary graphical parameters that will be passed to genericEGRETDotPlot function (see ?par for options)
#' @keywords graphics water-quality statistics
#' @export
Expand All @@ -36,7 +36,7 @@
#' plotResidTime(eList)
plotResidTime<-function(eList, stdResid = FALSE,
printTitle = TRUE, hLine=TRUE, tinyPlot=FALSE,col="black",lwd=1,
cex=0.8, cex.axis=1.1,cex.main=1.1, customPar=FALSE,rResid=FALSE,...){
cex=0.8, cex.axis=1.1,cex.main=1.1, customPar=FALSE,randomCensored=FALSE,...){

localINFO <- getInfo(eList)
localSample <- getSample(eList)
Expand Down Expand Up @@ -73,7 +73,7 @@ plotResidTime<-function(eList, stdResid = FALSE,

xInfo <- generalAxis(x=x, maxVal=xMax, minVal=xMin,padPercent=0, tinyPlot=tinyPlot)

if(!rResid){
if(!randomCensored){
yLow<-log(localSample$ConcLow)-localSample$yHat
yHigh<-log(localSample$ConcHigh)-localSample$yHat

Expand Down
Binary file modified inst/doc/EGRET.pdf
Binary file not shown.
Loading

0 comments on commit 7002524

Please sign in to comment.