Skip to content

Commit

Permalink
dealing with NA in summary for runBenchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
melina-leite committed Nov 13, 2024
1 parent be7efc8 commit 1166e1d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 7 additions & 0 deletions DHARMa/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
NOTE: for more news about the package, see https://github.com/florianhartig/DHARMa/releases

# DHARMa 0.4.8


## Minor changes

* fixing error in runBenchmarks


# DHARMa 0.4.7

Expand Down
10 changes: 7 additions & 3 deletions DHARMa/R/runBenchmarks.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,21 @@ runBenchmarks <- function(calculateStatistics, controlValues = NULL, nRep = 10,
summary = list()

# function for aggregation
aggreg <- function(f) {
aggreg <- function(f,...) {
ret <- aggregate(x[,- c(ncol(x) - 1, ncol(x))], by = list(x$controlValues), f)
colnames(ret)[1] = "controlValues"
return(ret)
}

sig <- function(x) mean(x < alpha)
if(length(is.na(x)>0)){
warning("NA values in the output, this might be a problem for the summaries.")
}

sig <- function(x) mean(x < alpha, na.rm=T)
isUnif <- function(x) ks.test(x, "punif")$p.value

summary$propSignificant = aggreg(sig)
summary$meanP = aggreg(mean)
summary$meanP = aggreg(mean, na.rm=T)
summary$isUnifP = aggreg(isUnif)

out = list()
Expand Down

0 comments on commit 1166e1d

Please sign in to comment.