-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from ldecicco-USGS/master
Randomized residuals.
- Loading branch information
Showing
31 changed files
with
516 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
EGRET 2.3.1 | ||
=========== | ||
* Removed unnecessary disclaimer. | ||
|
||
EGRET 2.2.0 | ||
=========== | ||
* Minor bug fixes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#' Create Randomized Residuals and Observations | ||
#' | ||
#' This function is used to add two columns to the Sample data frame: rResid and rObserved. | ||
#' rResid is the randomized residual value computed in log concentration units, and rObserved | ||
#' is the randomized 'observed' value of concentration in concentration units. | ||
#' | ||
#' @param eList named list with at least the Daily dataframe | ||
#' @keywords water-quality statistics | ||
#' @return eList named list with modified Daily data frame. | ||
#' @export | ||
#' @importFrom truncnorm rtruncnorm | ||
#' @examples | ||
#' eList <- Choptank_eList | ||
#' eList <- makeAugmentedSample(eList) | ||
makeAugmentedSample <- function(eList){ | ||
|
||
localSample <- eList$Sample | ||
numSamples<-length(localSample$Uncen) | ||
a <- ifelse(localSample$Uncen==0&!is.na(localSample$ConcLow),log(localSample$ConcLow)-localSample$yHat,-Inf) | ||
b <- ifelse(localSample$Uncen==1,+Inf,log(localSample$ConcHigh) - localSample$yHat) | ||
mean <- ifelse(localSample$Uncen==1,log(localSample$ConcHigh) - localSample$yHat,0) | ||
sd <- ifelse(localSample$Uncen==1,0,localSample$SE) | ||
localSample$rResid<-truncnorm::rtruncnorm(numSamples,a,b,mean,sd) | ||
localSample$rObserved <- exp(localSample$rResid + localSample$yHat) | ||
|
||
eList <- as.egret(eList$INFO, eList$Daily, localSample, eList$surfaces) | ||
return(eList) | ||
} | ||
|
||
# makeRandomResiduals <- function(eList){ | ||
# localSample <- eList$Sample | ||
# numSamples<-length(localSample$Uncen) | ||
# a <- ifelse(localSample$Uncen==0&!is.na(localSample$ConcLow),log(localSample$ConcLow)-localSample$yHat,-Inf) | ||
# b <- ifelse(localSample$Uncen==1,+Inf,log(localSample$ConcHigh) - localSample$yHat) | ||
# mean <- ifelse(localSample$Uncen==1,log(localSample$ConcHigh) - localSample$yHat,0) | ||
# sd <- ifelse(localSample$Uncen==1,0,localSample$SE) | ||
# localSample$rResid<-truncnorm::rtruncnorm(numSamples,a,b,mean,sd) | ||
# eList <- as.egret(eList$INFO, eList$Daily, localSample, eList$surfaces) | ||
# return(eList) | ||
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.