Skip to content
Snippets Groups Projects
Commit 7b55aa19 authored by thierrychambert's avatar thierrychambert
Browse files

Debugged issue due to NA results (plots)

parent 8e5e9dfc
Branches main
No related tags found
No related merge requests found
......@@ -101,7 +101,7 @@ ECDF_impact <- function(N, show_quantile = 0.95, sel_sc = "all", xlims = NULL,
# Add quantile vline
QT <- apply(-out[TH,,], 2, quantile, probs = show_quantile)
QT <- apply(-out[TH,,], 2, quantile, probs = show_quantile, na.rm = TRUE)
QT <- QT[-1]
if(sel_sc != "all") QT <- QT[sel_sc]
......
......@@ -40,7 +40,7 @@ density_impact <- function(N, show_CI = 0.95, center = "median", sel_sc = "all",
max_y <- c()
for(j in unique(df0$scenario)){
dd <- density(df0$impact[df0$scenario == j])
dd <- density(df0$impact[df0$scenario == j], na.rm = TRUE)
max_y[j] <- max(dd$y)
}
max_y <- max(max_y)
......@@ -113,7 +113,7 @@ density_impact <- function(N, show_CI = 0.95, center = "median", sel_sc = "all",
yend <- x <- c()
for(j in unique(dat$scenario)){
dd <- density(dat$impact[dat$scenario == j])
dd <- density(dat$impact[dat$scenario == j], na.rm = TRUE)
if(QT[1] == "mode"){
x[j] <- dd$x[which.max(dd$y)]
......@@ -129,7 +129,7 @@ density_impact <- function(N, show_CI = 0.95, center = "median", sel_sc = "all",
}
# Add LCI vlines
LCI <- apply(-out[TH,,], 2, quantile, probs = (1-show_CI)/2)
LCI <- apply(-out[TH,,], 2, quantile, probs = (1-show_CI)/2, na.rm = TRUE)
LCI <- LCI[-1]
yend <- get_density(dat = p$data, QT = LCI)$yend
......@@ -145,7 +145,7 @@ density_impact <- function(N, show_CI = 0.95, center = "median", sel_sc = "all",
# Add UCI vlines
UCI <- apply(-out[TH,,], 2, quantile, probs = 1-(1-show_CI)/2)
UCI <- apply(-out[TH,,], 2, quantile, probs = 1-(1-show_CI)/2, na.rm = TRUE)
UCI <- UCI[-1]
yend <- get_density(dat = p$data, QT = UCI)$yend
......@@ -165,7 +165,7 @@ density_impact <- function(N, show_CI = 0.95, center = "median", sel_sc = "all",
xQT <- get_density(dat = p$data, QT = "mode")$x
yend <- get_density(dat = p$data, QT = "mode")$yend
}else{
xQT <- apply(-out[TH,,], 2, quantile, probs = 0.5)
xQT <- apply(-out[TH,,], 2, quantile, probs = 0.5, na.rm = TRUE)
xQT <- xQT[-1]
yend <- get_density(dat = p$data, QT = xQT)$yend
if(sel_sc != "all") xQT <- xQT[sel_sc]
......
......@@ -46,6 +46,8 @@ plot_impact <- function(N, onset_year = NULL, sel_sc = "all", percent = TRUE, sh
CI <- apply(out[,,], c(1,3), quantile, probs = c(0.5, 1-(1-show_CI)/2, (1-show_CI)/2))
rownames(CI) <- c("avg", "lci", "uci")
# null scenario
CI["uci",,"sc0"] <- CI["lci",,"sc0"] <- CI["avg",,"sc0"]
# Build dataframe
if(sel_sc == "all"){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment