From 850cf46198446aa7eaf8095fd03ccc6e9ade30a8 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Wed, 16 May 2018 16:33:52 +0100 Subject: [PATCH 01/13] modification to have modup method1 --- R/modified_update.R | 192 ++++++++++++++++++++++++-------------------- 1 file changed, 103 insertions(+), 89 deletions(-) diff --git a/R/modified_update.R b/R/modified_update.R index 86a2579..22841e8 100644 --- a/R/modified_update.R +++ b/R/modified_update.R @@ -10,25 +10,25 @@ ##' this off of ##' ##' @export -modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use) { +modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, method = "method1") { year_min <- 2001 year_max <- 2030 - + sql <- paste("SELECT *", " FROM touchstone", " WHERE touchstone_name = $1", sep = "\n") touchstone_mod <- DBI::dbGetQuery(con, sql, touchstone_name_mod) - i <- touchstone_mod$id != '201510gavi-42' - touchstone_mod <- touchstone_mod[which.max(touchstone_mod$version[i]), ] + i <- touchstone_mod$id != '201510gavi-42' + touchstone_mod <- touchstone_mod[which.max(touchstone_mod$version[i]), ] modup_by_itself <- any(touchstone_name_mod == touchstone_use) meta <- mu_prepare(con, touchstone_mod$id, modup_by_itself = modup_by_itself) meta <- mu_impact_metadata(meta, touchstone_use) - + meta$touchstone_mod <- as.list(touchstone_mod[c("id", "touchstone_name", "version")]) meta$touchstone_use <- touchstone_use - + meta$group$touchstone_src <- meta$group$touchstone touchstone_src_native <- sub("-[0-9]{6}.*", "", meta$group$touchstone_name) meta$group$touchstone_name_dest <- @@ -37,21 +37,22 @@ modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use) "[%s] %s", ifelse(meta$group$activity_type == "routine", "Rout", "SIA"), meta$group$vaccine) - + ## This is quite slow to run but we can just pull it once: fmt <- "SELECT * FROM v_target_pop_%s WHERE YEAR BETWEEN %d AND %d" pop <- list( total = DBI::dbGetQuery(con, sprintf(fmt, "total", year_min, year_max)), routine = DBI::dbGetQuery(con, sprintf(fmt, "routine", year_min, year_max))) - - + + index <- meta$group$index data <- lapply(index, function(i) mu_build_data(con, i, meta, pop)) - + data <- rbind_simple(data) ## Perform the update itself the update: - data$deaths_averted_new <- mu_scale("deaths_averted", data) - data$cases_averted_new <- mu_scale("cases_averted", data) + data$deaths_averted_new <- mu_scale("deaths_averted", data, method) + data$cases_averted_new <- mu_scale("cases_averted", data, method) + meta$data <- data meta } @@ -79,27 +80,27 @@ modified_update_summary_output <- function(con, res, path_meta) { x[j] <- tr[[to]][i[j]] x } - + ## TODO: At the moment the metadata handling is very crude; the ## inputs are not properly documented or anything. meta_files <- c("gavi_country_data.csv", "tr_touchstone.csv", "years_output.csv") stopifnot(all(file.exists(file.path(path_meta, meta_files)))) - - + + ## Start on the meta group <- res$group - + ## TODO: we need to filter this to only include the "gavi focal model" ## for each disease. This will do for now: focal <- DBI::dbReadTable(con, "gavi_focal_model") focal$.code <- paste(focal$touchstone, focal$disease, focal$model, sep = "\n") group$is_focal <- paste(group$touchstone, group$disease, group$model, sep = "\n") %in% - focal$.code - + focal$.code + tr_touchstone <- read_csv("meta/tr_touchstone.csv") - + group_out <- data_frame( vaccine = group$vaccine, ## New columns @@ -111,10 +112,10 @@ modified_update_summary_output <- function(con, res, path_meta) { model = group$model, touchstone = group$touchstone_name, vaccine_delivery = group$vaccine_delivery) - + group_out$touchstone_short <- translate_vals(group$touchstone_name, tr_touchstone, "montagu_short") - + ## The metadata that we have on countries differs from what the shiny ## app has (e.g WHO region of EMR vs EMRO for AFG), so we'll use this: ## cmp <- read.csv("../gavi-shiny-app/data_20170117.csv", @@ -125,7 +126,7 @@ modified_update_summary_output <- function(con, res, path_meta) { ## write.csv(country, "meta/shiny/gavi_country_data.csv", row.names = FALSE) country <- read_csv(file.path(path_meta, "gavi_country_data.csv")) country$global <- NULL - + ## Which leaves us with the rest: ## ## TODO: this should be target_pop_estimated_new which needs to come @@ -146,17 +147,17 @@ modified_update_summary_output <- function(con, res, path_meta) { cases_averted = "cases_averted_new", fvps = "fvps_new", population = "target_pop_given_new") - + dat <- res$data[cols] names(dat) <- names(cols) tmp <- country[match(dat$country, country$country), setdiff(names(country), "country")] dat <- cbind(dat, tmp) rownames(dat) <- NULL - + dat_updated <- dat dat_updated[names(cols_update)] <- res$data[cols_update] - + group_out_updated <- group_out ## Makeup the suffix from res$touchstone_mod$touchstone_name name_suffix <- unlist(strsplit(res$touchstone_mod$touchstone_name, "-")) @@ -165,26 +166,26 @@ modified_update_summary_output <- function(con, res, path_meta) { paste0(sub("-[0-9]{6}.*", "", group_out$touchstone),"-", name_suffix ) stopifnot(all(group_out_updated$touchstone %in% - tr_touchstone$montagu)) + tr_touchstone$montagu)) group_out_updated$touchstone_short <- translate_vals(group_out_updated$touchstone, tr_touchstone, from = "montagu", to = "montagu_short") - + i <- match(res$data$index, res$group$index) d1 <- cbind(group_out[i, ], dat) d2 <- cbind(group_out_updated[i, ], dat_updated) d3 <- rbind(d1, d2) rownames(d3) <- NULL - + ## Filter output to a set of years per touchstone: keep <- read_csv("meta/years_output.csv") i <- logical(nrow(d3)) for (j in seq_len(nrow(keep))) { i[d3$touchstone == keep$touchstone[j] & - d3$year >= keep$year_from[j] & - d3$year <= keep$year_to[j]] <- TRUE + d3$year >= keep$year_from[j] & + d3$year <= keep$year_to[j]] <- TRUE } ## Exclude MCV1 i[d3$vaccine == "MCV1"] <- FALSE @@ -213,13 +214,13 @@ mu_prepare <- function(con, touchstone_new, modup_by_itself = FALSE) { whisker::whisker.render(txt, list(touchstone_new2 = touchstone_new2, touchstone_new = touchstone_new)) } - + views <- c("migrate_coverage", "burden_fvps", "impact", "coverage", "target_pop_total", "target_pop_routine") for (v in views) { DBI::dbExecute(con, temporary_view(v, read_sql(v))) } - + DBI::dbGetQuery(con, read_sql("query_metadata")) } @@ -229,14 +230,14 @@ mu_build_data <- function(con, index, meta, pop) { year_min <- min(pop$total$year) year_max <- max(pop$total$year) w <- 4L # 1/2 window for rolling average - + ## Process our arguments a bit more: x <- meta$group[meta$group$index == index, ]; print(x) xd <- meta$impacts[meta$impacts$index == index, ] x_deaths <- xd[xd$impact_outcome == "deaths_averted", ] x_cases <- xd[xd$impact_outcome == "cases_averted", ] x_fvps <- xd[xd$impact_outcome == "fvps_added", ] - + sql <- paste("SELECT country", " FROM touchstone_country", " WHERE touchstone = $1", @@ -244,22 +245,22 @@ mu_build_data <- function(con, index, meta, pop) { " ORDER BY country", sep = "\n") countries <- DBI::dbGetQuery(con, sql, list(x$touchstone, x$disease))[[1]] - + if (length(countries) == 0L) { stop("Import error") } - + window <- 2 * w + 1 year_max2 <- year_max + w years <- year_min:year_max2 n_years <- length(years) - + dat <- expand.grid(year = years, country = countries, index = index, stringsAsFactors = FALSE)[3:1] dat$.code <- paste(dat$country, dat$year, sep = "\r") - + merge_in <- function(dat, d, cols) { d$.code <- paste(d$country, d$year, sep = "\r") i <- match(dat$.code, d$.code) @@ -272,16 +273,16 @@ mu_build_data <- function(con, index, meta, pop) { } cbind(dat, keep) } - + ## 1. impact: sql <- paste("SELECT * FROM v_impact", " WHERE YEAR BETWEEN 2001 AND $2", " AND impact_estimate_set = $1") - + d_deaths_averted <- DBI::dbGetQuery(con, sql, list(x_deaths$impact_estimate_set, year_max2)) dat <- merge_in(dat, d_deaths_averted, c(deaths_averted = "value")) - + if (nrow(x_cases) == 0) { dat$cases_averted <- NA_real_ } else { @@ -289,7 +290,7 @@ mu_build_data <- function(con, index, meta, pop) { DBI::dbGetQuery(con, sql, list(x_cases$impact_estimate_set, year_max2)) dat <- merge_in(dat, d_cases_averted, c(cases_averted = "value")) } - + if (nrow(x_fvps) > 0) { d_fvps_added <- DBI::dbGetQuery(con, sql, list(x_fvps$impact_estimate_set, year_max2)) @@ -302,7 +303,7 @@ mu_build_data <- function(con, index, meta, pop) { d_fvps <- DBI::dbGetQuery(con, sql, list(x$burden_estimate_set, year_max2)) dat <- merge_in(dat, d_fvps, c(fvps = "value")) } - + ## 3. old coverage sql <- paste("SELECT * FROM v_coverage", " WHERE YEAR BETWEEN 2001 and $2", @@ -311,23 +312,24 @@ mu_build_data <- function(con, index, meta, pop) { dat <- merge_in(dat, mu_fix_coverage(d_cov_old), c(coverage_old = "coverage", coverage_target = "target")) - + ## 4. new coverage if (is.na(x$coverage_set_new)) { - stop("Import error: no new coverage found") + #stop("Import error: no new coverage found") + d_cov_new <- d_cov_old } else { if(meta$touchstone_mod$touchstone_name == meta$group$touchstone_name[meta$group$index == index]) { d_cov_new <- d_cov_old } else { d_cov_new <- DBI::dbGetQuery(con, sql, list(x$coverage_set_new, year_max2)) } - dat <- merge_in(dat, mu_fix_coverage(d_cov_new), - c(coverage_new = "coverage", - coverage_target_new = "target")) } - - - + dat <- merge_in(dat, mu_fix_coverage(d_cov_new), + c(coverage_new = "coverage", + coverage_target_new = "target")) + + + ## 5. population estimates pop_total <- pop$total[pop$total$demographic_source == x$demographic_source, ] pop_routine <- pop$routine[ @@ -335,9 +337,9 @@ mu_build_data <- function(con, index, meta, pop) { pop$routine$demographic_source == x$demographic_source, ] dat <- merge_in(dat, pop_total, c(pop_total = "value")) dat <- merge_in(dat, pop_routine, c(pop_routine = "value")) - + ## 6. Impact rates - + ## NOTE: There is some fiddling required here. We might have cases ## where there is nonzero impact but zero fvps. There are two forms ## of this! @@ -354,8 +356,8 @@ mu_build_data <- function(con, index, meta, pop) { ## the coverage_target is not known; those cases I've opted to just ## zero the rate calculation but leave the impact in. ## (we have such cases for routines as well.) - - + + i <- is_blank(dat$fvps) & !(is_blank(dat$deaths_averted) & is_blank(dat$cases_averted)) & !is_blank(dat$coverage_target) @@ -365,7 +367,7 @@ mu_build_data <- function(con, index, meta, pop) { ## Otherwise use pop_routine. dat$fvps[i] <- dat$coverage_old[i] * dat$coverage_target[i] } - + ## There are cases where we have blank fvps_old, but positive coverage_old ## This caused the Inf/-Inf impact rate issue for CHN and TCD ## We create synthetic fvps for such cases when applicable. @@ -378,10 +380,10 @@ mu_build_data <- function(con, index, meta, pop) { dat$fvps[i] <- dat$coverage_old[i] * dat$pop_routine[i] } } - + dat <- mu_calculate_rate("deaths", dat, window, n_years) dat <- mu_calculate_rate("cases", dat, window, n_years) - + ## And another quantity needed ## ## NOTE: Here, we can run into trouble where the coverage is zero @@ -390,10 +392,10 @@ mu_build_data <- function(con, index, meta, pop) { ## rolling calculation) dat$target_pop_estimated <- dat$fvps / dat$coverage_old dat$target_pop_estimated[dat$fvps > 0 & is_blank(dat$coverage_old)] <- NA - + dat$target_pop_estimated_avg <- roll_mean_by(dat$target_pop_estimated, window, n_years) - + if (x$activity_type == "routine") { dat$target_pop_given <- dat$pop_routine dat$target_pop_given_new <- dat$pop_routine @@ -401,12 +403,12 @@ mu_build_data <- function(con, index, meta, pop) { dat$target_pop_given <- dat$coverage_target dat$target_pop_given_new <- dat$coverage_target_new } - + ## We also want new fvps which we compute as coverage * target pop v <- if (x$activity_type == "campaign") "coverage_target_new" else "pop_routine" dat$fvps_new <- dat$coverage_new * dat[[v]] - + ## At the moment we can do nothing for MHL, TUV and XK, because we have no routine pop for them i <- !is_blank(dat$coverage_new) & is_blank(dat$fvps_new) & dat$year < 2031#& !is_blank(dat$target_pop_estimated) if (any(i)) { @@ -422,18 +424,18 @@ mu_build_data <- function(con, index, meta, pop) { ## drop excess temporary things dat$.code <- NULL dat <- dat[dat$year <= year_max, ] - + dat } mu_impact_metadata <- function(meta, touchstone_use) { meta <- meta[meta$touchstone_name %in% touchstone_use, ] rownames(meta) <- NULL - + vary <- c("impact_outcome", "impact_estimate_set", "impact_estimate_recipe", "focal_ingredient") same <- setdiff(names(meta), vary) - + f <- function(y) { n <- vapply(y, function(x) length(unique(x)), integer(1)) stopifnot(all(n[same] == 1)) @@ -443,16 +445,16 @@ mu_impact_metadata <- function(meta, touchstone_use) { meta$vaccine, meta$activity_type, meta$support_type, meta$responsibility, sep = "\r") meta_code <- factor(meta_code, unique(meta_code)) - + i1 <- unname(tapply(seq_along(meta_code), meta_code, min)) group <- meta[i1, same] group$index <- seq_len(nrow(group)) rownames(group) <- NULL - + impacts <- meta[vary] impacts$index <- group$index[tapply(meta_code, meta_code)] impacts <- impacts[order(impacts$index, impacts$impact_outcome), ] - + list(group = group, impacts = impacts) } @@ -464,12 +466,24 @@ mu_impact_metadata <- function(meta, touchstone_use) { ##' @param d Data: use impact_rate_tot (method 2) ##' ##' @export -mu_scale <- function(name, d) { - ## This chunck becomes simpler, since only method 2 is used throughout. - rate_tot_old <- d[[paste0(name, "_rate_tot")]] - fvps_new <- d$fvps_new - - ret <- fvps_new * rate_tot_old +mu_scale <- function(name, d, method = "method2") { + ## This chunck becomes simpler, since only method 2 is used throughout. - Not any more, we need method 1 now. + ## This is method 1. + if (method != "method2") { + # by default use impact_new = impact_old / coverage_old * coverage_new + ret <- d[[name]] / d$coverage_old * d$coverage_new + + # when coverage_old is NA or 0, use impact_rate_tot*fvps_new + i <- is.na(d[[name]]) | d[[name]] == 0 + rate_tot_old <- d[[paste0(name, "_rate_tot")]] + fvps_new <- d$fvps_new + ret[i] <- fvps_new[i] * rate_tot_old[i] + } else { + ## This is method 2 + rate_tot_old <- d[[paste0(name, "_rate_tot")]] + fvps_new <- d$fvps_new + ret <- fvps_new * rate_tot_old + } ret[!is.finite(ret)] <- NA j <- !is.na(d$coverage_new) & d$coverage_new == 0 ret[j] <- 0 @@ -494,19 +508,19 @@ mu_fix_coverage <- function(d) { } v } - + code <- make_code(args = d[c("coverage_set", "country", "year")]) n <- table(code) fix <- code %in% as.integer(names(n[n > 1])) - + d_fix <- d[fix, ] i <- code[fix] - + tmp <- d_fix[tapply(seq_along(i), i, utils::head, 1), ] tmp$target <- unname(tapply(d_fix$target, i, sum, na.rm = TRUE)) reached <- tapply(d_fix$coverage * d_fix$target, i, sum, na.rm = TRUE) tmp$coverage <- unname(reached / tmp$target) - + ret <- rbind(d[!fix, ], tmp) ret[order(ret$coverage_set, ret$country, ret$year), ] } @@ -518,19 +532,19 @@ mu_calculate_rate <- function(name, dat, window, n_years) { v_tot <- sprintf("%s_averted_rate_tot", name) v_use <- sprintf("%s_averted_rate", name) v_type <- sprintf("%s_averted_rate_type", name) - + dat[[v_inst]] <- dat[[v_averted]] / dat$fvps dat[[v_inst]][ is_blank(dat$fvps) & !is_blank(dat[[v_averted]])] <- NA - + dat[[v_avg]] <- roll_sum_by(dat[[v_averted]], window, n_years) / roll_sum_by(dat$fvps, window, n_years) - + dat[[v_tot]] <- roll_sum_by(dat[[v_averted]], Inf, n_years) / roll_sum_by(dat$fvps, Inf, n_years) - + ## Some cases don't have any non-NA rates type <- rep(NA, nrow(dat)) use <- rep(NA_real_, nrow(dat)) @@ -538,10 +552,10 @@ mu_calculate_rate <- function(name, dat, window, n_years) { i <- !is.na(dat[[v_tot]]) type[i] <- "tot" use[i] <- dat[[v_tot]][i] - + dat[[v_use]] <- use dat[[v_type]] <- type - + dat } @@ -562,15 +576,15 @@ mu_year_introduction <- function(con, dat, dat_summary){ meta.group <- unique(group[meta.group]) x <- merge(meta.group, dat_summary, by = c("touchstone", "modelling_group", "vaccine"), all.y=TRUE) stopifnot( nrow(x) == nrow(dat_summary) ) - + x$touchstone_src[ is.na(x$touchstone_src) ] <- dat$touchstone_mod$id - + coverage.touchstone <- as.list(c(unique(x$touchstone_src))) - + y <- do.call(rbind, lapply(coverage.touchstone, function(i) find_year_introduction(con, i))) - + z <- merge(x, y, by=c("touchstone_src", "activity_type", "vaccine", "country"), all.x = TRUE) - + z } From 4defb4b829a0e01edba9ef61756d5c09367411d5 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Wed, 16 May 2018 17:07:51 +0100 Subject: [PATCH 02/13] add gavi_support to v_coverage, so that we can do method2_version2 --- R/modified_update.R | 13 ++++++++++--- inst/sql/modified_update/coverage.sql | 1 + man/modified_update_calculate.Rd | 3 ++- man/mu_scale.Rd | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/R/modified_update.R b/R/modified_update.R index 22841e8..63061e5 100644 --- a/R/modified_update.R +++ b/R/modified_update.R @@ -10,7 +10,7 @@ ##' this off of ##' ##' @export -modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, method = "method1") { +modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, method = "method2") { year_min <- 2001 year_max <- 2030 @@ -23,6 +23,12 @@ modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, touchstone_mod <- touchstone_mod[which.max(touchstone_mod$version[i]), ] modup_by_itself <- any(touchstone_name_mod == touchstone_use) meta <- mu_prepare(con, touchstone_mod$id, modup_by_itself = modup_by_itself) + + ## we are going to do mothod2 version 2 + ## this method do original modup2 for total support, and then derive gavi_support by filtering per-year gavi_support + if(method == "method2_v2") { + meta <- meta[meta$support_type == "total", ] + } meta <- mu_impact_metadata(meta, touchstone_use) meta$touchstone_mod <- @@ -326,7 +332,8 @@ mu_build_data <- function(con, index, meta, pop) { } dat <- merge_in(dat, mu_fix_coverage(d_cov_new), c(coverage_new = "coverage", - coverage_target_new = "target")) + coverage_target_new = "target", + gavi_support_new = "gavi_support")) @@ -469,7 +476,7 @@ mu_impact_metadata <- function(meta, touchstone_use) { mu_scale <- function(name, d, method = "method2") { ## This chunck becomes simpler, since only method 2 is used throughout. - Not any more, we need method 1 now. ## This is method 1. - if (method != "method2") { + if (method == "method1") { # by default use impact_new = impact_old / coverage_old * coverage_new ret <- d[[name]] / d$coverage_old * d$coverage_new diff --git a/inst/sql/modified_update/coverage.sql b/inst/sql/modified_update/coverage.sql index 9a83f4e..84a4c17 100644 --- a/inst/sql/modified_update/coverage.sql +++ b/inst/sql/modified_update/coverage.sql @@ -2,6 +2,7 @@ SELECT coverage_set, coverage.country, coverage.year, coverage, + gavi_support, target FROM coverage ORDER BY coverage_set, country, year diff --git a/man/modified_update_calculate.Rd b/man/modified_update_calculate.Rd index fea71ea..fce7af3 100644 --- a/man/modified_update_calculate.Rd +++ b/man/modified_update_calculate.Rd @@ -4,7 +4,8 @@ \alias{modified_update_calculate} \title{Do a modified update} \usage{ -modified_update_calculate(con, touchstone_name_mod, touchstone_use) +modified_update_calculate(con, touchstone_name_mod, touchstone_use, + method = "method2") } \arguments{ \item{con}{Database connection} diff --git a/man/mu_scale.Rd b/man/mu_scale.Rd index e8a3c5a..0dbdd01 100644 --- a/man/mu_scale.Rd +++ b/man/mu_scale.Rd @@ -4,7 +4,7 @@ \alias{mu_scale} \title{Calculate updated impact} \usage{ -mu_scale(name, d) +mu_scale(name, d, method = "method2") } \arguments{ \item{name}{Impact type: deaths_averted or cases_averted} From cdb2c954b20286b10780495b4ad7db5c12b53a1c Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Wed, 16 May 2018 17:18:10 +0100 Subject: [PATCH 03/13] remove MCV1 from modup if coverage touchstone is sdf9 --- R/modified_update.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R/modified_update.R b/R/modified_update.R index 63061e5..300bfa5 100644 --- a/R/modified_update.R +++ b/R/modified_update.R @@ -23,7 +23,10 @@ modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, touchstone_mod <- touchstone_mod[which.max(touchstone_mod$version[i]), ] modup_by_itself <- any(touchstone_name_mod == touchstone_use) meta <- mu_prepare(con, touchstone_mod$id, modup_by_itself = modup_by_itself) - + ## 201403gavi - SDF9 - does not have MCV1 coverage, we need to get rid of it here to avoid error + if (touchstone_name_mod == "201403gavi") { + meta <- meta[meta$vaccine != "MCV1", ] + } ## we are going to do mothod2 version 2 ## this method do original modup2 for total support, and then derive gavi_support by filtering per-year gavi_support if(method == "method2_v2") { @@ -321,8 +324,7 @@ mu_build_data <- function(con, index, meta, pop) { ## 4. new coverage if (is.na(x$coverage_set_new)) { - #stop("Import error: no new coverage found") - d_cov_new <- d_cov_old + stop("Import error: no new coverage found") } else { if(meta$touchstone_mod$touchstone_name == meta$group$touchstone_name[meta$group$index == index]) { d_cov_new <- d_cov_old From 8dcf93ea06618bb7b855a6dd13a96bf8c1f6cc0c Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Tue, 22 May 2018 12:11:31 +0100 Subject: [PATCH 04/13] add codes for method2 version2 --- R/modified_update.R | 38 +++++++++++++++++++++++++++++--- man/modified_update_calculate.Rd | 7 +++++- man/mu_scale.Rd | 2 ++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/R/modified_update.R b/R/modified_update.R index 300bfa5..03d5ada 100644 --- a/R/modified_update.R +++ b/R/modified_update.R @@ -9,8 +9,13 @@ ##' @param touchstone_use Name of the touchstone that we are basing ##' this off of ##' +##' @param method two options: method1, method2 +##' method2_v2 is different from method2 in that, it takes per-year-gavi-level as an imput for gavi impact +##' +##' @param version two options: v1 and v2 +##' ##' @export -modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, method = "method2") { +modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, method = "method2", version = "v2") { year_min <- 2001 year_max <- 2030 @@ -23,13 +28,13 @@ modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, touchstone_mod <- touchstone_mod[which.max(touchstone_mod$version[i]), ] modup_by_itself <- any(touchstone_name_mod == touchstone_use) meta <- mu_prepare(con, touchstone_mod$id, modup_by_itself = modup_by_itself) - ## 201403gavi - SDF9 - does not have MCV1 coverage, we need to get rid of it here to avoid error + ## 201403gavi - SDF9 - does not have MCV1 coverage, we need to get rid of it to avoid triggering error message if (touchstone_name_mod == "201403gavi") { meta <- meta[meta$vaccine != "MCV1", ] } ## we are going to do mothod2 version 2 ## this method do original modup2 for total support, and then derive gavi_support by filtering per-year gavi_support - if(method == "method2_v2") { + if(method == "method2" & version == "v2") { meta <- meta[meta$support_type == "total", ] } meta <- mu_impact_metadata(meta, touchstone_use) @@ -63,6 +68,32 @@ modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, data$cases_averted_new <- mu_scale("cases_averted", data, method) meta$data <- data + + if(version == "v2") { + ## with version 2, gavi impact is filtered from total impact by per-year-gavi-level + group <- meta$group + impacts <- meta$impacts + + v <- group + v$support_type <- "gavi" + v$index <- max(v$index) + v$index + meta$group <- rbind(group, v) + + v <- impacts + v$index <- max(v$index) + v$index + meta$impacts <- rbind(impacts, v) + + v <- data + i <- !is.na(v$gavi_support_new) & !v$gavi_support_new + v$coverage_new[i] <- 0. + v$coverage_target_new[i] <- 0. + v$target_pop_given_new[i] <- 0. + v$fvps_new[i] <- 0. + v$deaths_averted_new[i] <- 0. + v$cases_averted_new[i] <- 0. + meta$data <- rbind(data, v) + } + meta } @@ -474,6 +505,7 @@ mu_impact_metadata <- function(meta, touchstone_use) { ##' ##' @param d Data: use impact_rate_tot (method 2) ##' +##' @param method two options: method1 and method2 ##' @export mu_scale <- function(name, d, method = "method2") { ## This chunck becomes simpler, since only method 2 is used throughout. - Not any more, we need method 1 now. diff --git a/man/modified_update_calculate.Rd b/man/modified_update_calculate.Rd index fce7af3..4e900f9 100644 --- a/man/modified_update_calculate.Rd +++ b/man/modified_update_calculate.Rd @@ -5,7 +5,7 @@ \title{Do a modified update} \usage{ modified_update_calculate(con, touchstone_name_mod, touchstone_use, - method = "method2") + method = "method2", version = "v2") } \arguments{ \item{con}{Database connection} @@ -15,6 +15,11 @@ that we are creating} \item{touchstone_use}{Name of the touchstone that we are basing this off of} + +\item{method}{two options: method1, method2 +method2_v2 is different from method2 in that, it takes per-year-gavi-level as an imput for gavi impact} + +\item{version}{two options: v1 and v2} } \description{ Do a modified update diff --git a/man/mu_scale.Rd b/man/mu_scale.Rd index 0dbdd01..985cb9a 100644 --- a/man/mu_scale.Rd +++ b/man/mu_scale.Rd @@ -10,6 +10,8 @@ mu_scale(name, d, method = "method2") \item{name}{Impact type: deaths_averted or cases_averted} \item{d}{Data: use impact_rate_tot (method 2)} + +\item{method}{two options: method1 and method2} } \description{ Calculate updated impact From 182dfd1b6092cd77e9b3183294f04fcc56735088 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Tue, 22 May 2018 12:34:19 +0100 Subject: [PATCH 05/13] undo set pop_new = 0 --- R/modified_update.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/modified_update.R b/R/modified_update.R index 03d5ada..36d0019 100644 --- a/R/modified_update.R +++ b/R/modified_update.R @@ -84,10 +84,10 @@ modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, meta$impacts <- rbind(impacts, v) v <- data + v$index <- max(v$index) + v$index i <- !is.na(v$gavi_support_new) & !v$gavi_support_new v$coverage_new[i] <- 0. v$coverage_target_new[i] <- 0. - v$target_pop_given_new[i] <- 0. v$fvps_new[i] <- 0. v$deaths_averted_new[i] <- 0. v$cases_averted_new[i] <- 0. From 1d660044a51409a63b49c47aed3e8559d56b3ef4 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Tue, 22 May 2018 12:56:08 +0100 Subject: [PATCH 06/13] use per-year-gavi-level for native touchstone as well --- R/modified_update.R | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/R/modified_update.R b/R/modified_update.R index 36d0019..2004dac 100644 --- a/R/modified_update.R +++ b/R/modified_update.R @@ -85,9 +85,14 @@ modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, v <- data v$index <- max(v$index) + v$index + i <- !is.na(v$gavi_support) & !v$gavi_support + v$coverage_old[i] <- 0. + v$fvps[i] <- 0. + v$deaths_averted[i] <- 0. + v$cases_averted[i] <- 0. + i <- !is.na(v$gavi_support_new) & !v$gavi_support_new v$coverage_new[i] <- 0. - v$coverage_target_new[i] <- 0. v$fvps_new[i] <- 0. v$deaths_averted_new[i] <- 0. v$cases_averted_new[i] <- 0. @@ -351,7 +356,7 @@ mu_build_data <- function(con, index, meta, pop) { d_cov_old <- DBI::dbGetQuery(con, sql, list(x$coverage_set, year_max2)) dat <- merge_in(dat, mu_fix_coverage(d_cov_old), - c(coverage_old = "coverage", coverage_target = "target")) + c(coverage_old = "coverage", coverage_target = "target", gavi_support = "gavi_support")) ## 4. new coverage if (is.na(x$coverage_set_new)) { From 9b6229ba860433163363d336e682515bfba33393 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Tue, 22 May 2018 13:07:34 +0100 Subject: [PATCH 07/13] stop if method/version combination is not correct --- R/modified_update.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/modified_update.R b/R/modified_update.R index 2004dac..24be37e 100644 --- a/R/modified_update.R +++ b/R/modified_update.R @@ -16,6 +16,9 @@ ##' ##' @export modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, method = "method2", version = "v2") { + if(method != "method2" & version == "v2") { + stop("version 2 can only be applied to method 2.") + } year_min <- 2001 year_max <- 2030 From 2f4afbd92b7711740acc3297f87874926696bb01 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Fri, 1 Jun 2018 13:49:20 +0100 Subject: [PATCH 08/13] enable to add per-year-gavi-level in the output --- R/modified_update.R | 2 ++ inst/sql/modified_update/migrate_coverage.sql | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/R/modified_update.R b/R/modified_update.R index 24be37e..d7ff201 100644 --- a/R/modified_update.R +++ b/R/modified_update.R @@ -182,6 +182,7 @@ modified_update_summary_output <- function(con, res, path_meta) { cols <- c(country = "country", year = "year", coverage = "coverage_old", + gavi_support = "gavi_support", population = "target_pop_given", population_estimated = "target_pop_estimated", deaths_averted_rate = "deaths_averted_rate", @@ -191,6 +192,7 @@ modified_update_summary_output <- function(con, res, path_meta) { cases_averted = "cases_averted", cases_averted_rate = "cases_averted_rate") cols_update <- c(coverage = "coverage_new", + gavi_support = "gavi_support_new", deaths_averted = "deaths_averted_new", cases_averted = "cases_averted_new", fvps = "fvps_new", diff --git a/inst/sql/modified_update/migrate_coverage.sql b/inst/sql/modified_update/migrate_coverage.sql index 09d4088..97c3bf8 100644 --- a/inst/sql/modified_update/migrate_coverage.sql +++ b/inst/sql/modified_update/migrate_coverage.sql @@ -9,6 +9,9 @@ LEFT JOIN (SELECT coverage_set.* FROM coverage_set JOIN touchstone ON touchstone.id = coverage_set.touchstone WHERE touchstone = '{{{touchstone_new}}}' AND (coverage_set.gavi_support_level = 'with' - OR coverage_set.gavi_support_level = 'bestminus') )AS coverage_new + OR coverage_set.gavi_support_level = 'bestminus') + AND name NOT IN ('Rota: MCV1, with, routine', + 'Hib: MCV1, with, routine', + 'PCV: MCV1, with, routine'))AS coverage_new ON coverage_old.vaccine = coverage_new.vaccine AND coverage_old.activity_type = coverage_new.activity_type From f2eb16f7e638066d9fb5955a2ccf41b168b37059 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Mon, 4 Jun 2018 11:02:16 +0100 Subject: [PATCH 09/13] add to NEWS --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 4f04375..2523c55 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,5 @@ +### jenner 0.0.16 + * VIMC-1738 modup method 1, method 2 verison 2 (gavi impact filtered from total impact by per-year-gavi-level) ### jenner 0.0.15 * VIMC-14628 impact_method2 sql modification post Wes' touchstone fast forward From 8395ad987f67a06ae2cc0901e27102177d2993e3 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Mon, 4 Jun 2018 11:02:50 +0100 Subject: [PATCH 10/13] increase version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9cd5179..4477460 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: jenner Title: Internal Montagu Helpers -Version: 0.0.15 +Version: 0.0.16 Description: Helpers for Montagu. License: MIT + file LICENSE Author: Rich FitzJohn From ac42d3e426026c95dbabf89f14443215ce6605d6 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Mon, 4 Jun 2018 11:56:37 +0100 Subject: [PATCH 11/13] add comments + a little bit styling --- R/modified_update.R | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/R/modified_update.R b/R/modified_update.R index d7ff201..dc58463 100644 --- a/R/modified_update.R +++ b/R/modified_update.R @@ -16,7 +16,12 @@ ##' ##' @export modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, method = "method2", version = "v2") { - if(method != "method2" & version == "v2") { + ### current method and version we have + ### method 1 version 1 - impact new = impact old / coverage old * coverage new + ### method 2 version 1 - Rich develpped this in July 2017 + ### method 2 version 2 - in version 2, total impact is the same as version 1, + ### gavi impact is a subset of total impact by filtering per-year-gavi-level + if (method != "method2" & version == "v2") { stop("version 2 can only be applied to method 2.") } year_min <- 2001 @@ -27,6 +32,8 @@ modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, " WHERE touchstone_name = $1", sep = "\n") touchstone_mod <- DBI::dbGetQuery(con, sql, touchstone_name_mod) + ### touchstone 201510gavi-42 is imported from Rshiny, it contains Rubella only + ### It is not a target touchstone we are interested in. i <- touchstone_mod$id != '201510gavi-42' touchstone_mod <- touchstone_mod[which.max(touchstone_mod$version[i]), ] modup_by_itself <- any(touchstone_name_mod == touchstone_use) @@ -37,7 +44,7 @@ modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, } ## we are going to do mothod2 version 2 ## this method do original modup2 for total support, and then derive gavi_support by filtering per-year gavi_support - if(method == "method2" & version == "v2") { + if (method == "method2" & version == "v2") { meta <- meta[meta$support_type == "total", ] } meta <- mu_impact_metadata(meta, touchstone_use) @@ -72,7 +79,7 @@ modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, meta$data <- data - if(version == "v2") { + if (version == "v2") { ## with version 2, gavi impact is filtered from total impact by per-year-gavi-level group <- meta$group impacts <- meta$impacts @@ -249,7 +256,7 @@ mu_prepare <- function(con, touchstone_new, modup_by_itself = FALSE) { ## this duplication later. ## sometimes we do modup for touchstone_old = touchstone_new ## the if-else clause is important to deal with this - if(modup_by_itself) { + if (modup_by_itself) { touchstone_new2 <- NULL } else { touchstone_new2 <- touchstone_new @@ -367,7 +374,7 @@ mu_build_data <- function(con, index, meta, pop) { if (is.na(x$coverage_set_new)) { stop("Import error: no new coverage found") } else { - if(meta$touchstone_mod$touchstone_name == meta$group$touchstone_name[meta$group$index == index]) { + if (meta$touchstone_mod$touchstone_name == meta$group$touchstone_name[meta$group$index == index]) { d_cov_new <- d_cov_old } else { d_cov_new <- DBI::dbGetQuery(con, sql, list(x$coverage_set_new, year_max2)) @@ -424,9 +431,9 @@ mu_build_data <- function(con, index, meta, pop) { i <- is_blank(dat$fvps) & !is_blank(dat$coverage_old) if (any(i)) { message("Creating synthetic fvps for ", x$model) - if((x$activity_type == "campaign")){ + if ((x$activity_type == "campaign")){ dat$fvps[i] <- dat$coverage_old[i] * dat$coverage_target[i] - }else{ + } else { dat$fvps[i] <- dat$coverage_old[i] * dat$pop_routine[i] } } @@ -469,7 +476,7 @@ mu_build_data <- function(con, index, meta, pop) { stop("modified update error") } #For analysis purpose, a touchstone can be 'updated' by itself - assumes equal fvps - if(meta$touchstone_mod$touchstone_name == meta$group$touchstone_name[meta$group$index == index]) + if (meta$touchstone_mod$touchstone_name == meta$group$touchstone_name[meta$group$index == index]) dat$fvps_new <- dat$fvps ## drop excess temporary things dat$.code <- NULL @@ -518,7 +525,7 @@ mu_impact_metadata <- function(meta, touchstone_use) { ##' @param method two options: method1 and method2 ##' @export mu_scale <- function(name, d, method = "method2") { - ## This chunck becomes simpler, since only method 2 is used throughout. - Not any more, we need method 1 now. + ## AS we need method 1 now. mu_scale includes both method 1 and method 2 now ## This is method 1. if (method == "method1") { # by default use impact_new = impact_old / coverage_old * coverage_new From 5d4cdd45e583e0121479fefeb195ef77e47a90ef Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Tue, 5 Jun 2018 09:19:08 +0100 Subject: [PATCH 12/13] use integer method and version --- R/modified_update.R | 27 +++++++++++++++------------ man/modified_update_calculate.Rd | 6 +++--- man/mu_scale.Rd | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/R/modified_update.R b/R/modified_update.R index dc58463..2bdd5d8 100644 --- a/R/modified_update.R +++ b/R/modified_update.R @@ -9,19 +9,22 @@ ##' @param touchstone_use Name of the touchstone that we are basing ##' this off of ##' -##' @param method two options: method1, method2 +##' @param method two options: 1 = method1, 2 = method2 ##' method2_v2 is different from method2 in that, it takes per-year-gavi-level as an imput for gavi impact ##' -##' @param version two options: v1 and v2 +##' @param version two options: 1 = v1 and 2 = v2 ##' ##' @export -modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, method = "method2", version = "v2") { +modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, method = 2, version = 1) { ### current method and version we have - ### method 1 version 1 - impact new = impact old / coverage old * coverage new - ### method 2 version 1 - Rich develpped this in July 2017 - ### method 2 version 2 - in version 2, total impact is the same as version 1, - ### gavi impact is a subset of total impact by filtering per-year-gavi-level - if (method != "method2" & version == "v2") { + ### method = 1 version = 1: impact new = impact old / coverage old * coverage new (or impact rate * fvps when coverage old in (NA/0)) + ### method = 2 version = 1: Rich develpped this in July 2017 + ### method = 2 version = 2: in version 2, total impact is the same as version 1, + ### gavi impact is a subset of total impact by filtering per-year-gavi-level + if (!(method %in% 1:2)) { + stop("currently, only method 1 and 2 have been developed.") + } + if (method != 2 & version == 2) { stop("version 2 can only be applied to method 2.") } year_min <- 2001 @@ -44,7 +47,7 @@ modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, } ## we are going to do mothod2 version 2 ## this method do original modup2 for total support, and then derive gavi_support by filtering per-year gavi_support - if (method == "method2" & version == "v2") { + if (method == 2 & version == 2) { meta <- meta[meta$support_type == "total", ] } meta <- mu_impact_metadata(meta, touchstone_use) @@ -79,7 +82,7 @@ modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, meta$data <- data - if (version == "v2") { + if (version == 2) { ## with version 2, gavi impact is filtered from total impact by per-year-gavi-level group <- meta$group impacts <- meta$impacts @@ -524,10 +527,10 @@ mu_impact_metadata <- function(meta, touchstone_use) { ##' ##' @param method two options: method1 and method2 ##' @export -mu_scale <- function(name, d, method = "method2") { +mu_scale <- function(name, d, method = 2) { ## AS we need method 1 now. mu_scale includes both method 1 and method 2 now ## This is method 1. - if (method == "method1") { + if (method == 1) { # by default use impact_new = impact_old / coverage_old * coverage_new ret <- d[[name]] / d$coverage_old * d$coverage_new diff --git a/man/modified_update_calculate.Rd b/man/modified_update_calculate.Rd index 4e900f9..26b50bf 100644 --- a/man/modified_update_calculate.Rd +++ b/man/modified_update_calculate.Rd @@ -5,7 +5,7 @@ \title{Do a modified update} \usage{ modified_update_calculate(con, touchstone_name_mod, touchstone_use, - method = "method2", version = "v2") + method = 2, version = 1) } \arguments{ \item{con}{Database connection} @@ -16,10 +16,10 @@ that we are creating} \item{touchstone_use}{Name of the touchstone that we are basing this off of} -\item{method}{two options: method1, method2 +\item{method}{two options: 1 = method1, 2 = method2 method2_v2 is different from method2 in that, it takes per-year-gavi-level as an imput for gavi impact} -\item{version}{two options: v1 and v2} +\item{version}{two options: 1 = v1 and 2 = v2} } \description{ Do a modified update diff --git a/man/mu_scale.Rd b/man/mu_scale.Rd index 985cb9a..9b850d4 100644 --- a/man/mu_scale.Rd +++ b/man/mu_scale.Rd @@ -4,7 +4,7 @@ \alias{mu_scale} \title{Calculate updated impact} \usage{ -mu_scale(name, d, method = "method2") +mu_scale(name, d, method = 2) } \arguments{ \item{name}{Impact type: deaths_averted or cases_averted} From 4054c70d2764ce57c9af83cf8b04070ecfc11cce Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Wed, 6 Jun 2018 12:48:11 +0100 Subject: [PATCH 13/13] remove version 2 scripts, it cannot be resolved here --- R/modified_update.R | 54 ++------------------------- inst/sql/modified_update/coverage.sql | 1 - man/modified_update_calculate.Rd | 4 +- 3 files changed, 4 insertions(+), 55 deletions(-) diff --git a/R/modified_update.R b/R/modified_update.R index 2bdd5d8..b2b88b2 100644 --- a/R/modified_update.R +++ b/R/modified_update.R @@ -12,21 +12,11 @@ ##' @param method two options: 1 = method1, 2 = method2 ##' method2_v2 is different from method2 in that, it takes per-year-gavi-level as an imput for gavi impact ##' -##' @param version two options: 1 = v1 and 2 = v2 -##' ##' @export -modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, method = 2, version = 1) { - ### current method and version we have - ### method = 1 version = 1: impact new = impact old / coverage old * coverage new (or impact rate * fvps when coverage old in (NA/0)) - ### method = 2 version = 1: Rich develpped this in July 2017 - ### method = 2 version = 2: in version 2, total impact is the same as version 1, - ### gavi impact is a subset of total impact by filtering per-year-gavi-level +modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, method = 2) { if (!(method %in% 1:2)) { stop("currently, only method 1 and 2 have been developed.") } - if (method != 2 & version == 2) { - stop("version 2 can only be applied to method 2.") - } year_min <- 2001 year_max <- 2030 @@ -45,11 +35,6 @@ modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, if (touchstone_name_mod == "201403gavi") { meta <- meta[meta$vaccine != "MCV1", ] } - ## we are going to do mothod2 version 2 - ## this method do original modup2 for total support, and then derive gavi_support by filtering per-year gavi_support - if (method == 2 & version == 2) { - meta <- meta[meta$support_type == "total", ] - } meta <- mu_impact_metadata(meta, touchstone_use) meta$touchstone_mod <- @@ -82,36 +67,6 @@ modified_update_calculate <- function(con, touchstone_name_mod, touchstone_use, meta$data <- data - if (version == 2) { - ## with version 2, gavi impact is filtered from total impact by per-year-gavi-level - group <- meta$group - impacts <- meta$impacts - - v <- group - v$support_type <- "gavi" - v$index <- max(v$index) + v$index - meta$group <- rbind(group, v) - - v <- impacts - v$index <- max(v$index) + v$index - meta$impacts <- rbind(impacts, v) - - v <- data - v$index <- max(v$index) + v$index - i <- !is.na(v$gavi_support) & !v$gavi_support - v$coverage_old[i] <- 0. - v$fvps[i] <- 0. - v$deaths_averted[i] <- 0. - v$cases_averted[i] <- 0. - - i <- !is.na(v$gavi_support_new) & !v$gavi_support_new - v$coverage_new[i] <- 0. - v$fvps_new[i] <- 0. - v$deaths_averted_new[i] <- 0. - v$cases_averted_new[i] <- 0. - meta$data <- rbind(data, v) - } - meta } @@ -192,7 +147,6 @@ modified_update_summary_output <- function(con, res, path_meta) { cols <- c(country = "country", year = "year", coverage = "coverage_old", - gavi_support = "gavi_support", population = "target_pop_given", population_estimated = "target_pop_estimated", deaths_averted_rate = "deaths_averted_rate", @@ -202,7 +156,6 @@ modified_update_summary_output <- function(con, res, path_meta) { cases_averted = "cases_averted", cases_averted_rate = "cases_averted_rate") cols_update <- c(coverage = "coverage_new", - gavi_support = "gavi_support_new", deaths_averted = "deaths_averted_new", cases_averted = "cases_averted_new", fvps = "fvps_new", @@ -371,7 +324,7 @@ mu_build_data <- function(con, index, meta, pop) { d_cov_old <- DBI::dbGetQuery(con, sql, list(x$coverage_set, year_max2)) dat <- merge_in(dat, mu_fix_coverage(d_cov_old), - c(coverage_old = "coverage", coverage_target = "target", gavi_support = "gavi_support")) + c(coverage_old = "coverage", coverage_target = "target")) ## 4. new coverage if (is.na(x$coverage_set_new)) { @@ -385,8 +338,7 @@ mu_build_data <- function(con, index, meta, pop) { } dat <- merge_in(dat, mu_fix_coverage(d_cov_new), c(coverage_new = "coverage", - coverage_target_new = "target", - gavi_support_new = "gavi_support")) + coverage_target_new = "target")) diff --git a/inst/sql/modified_update/coverage.sql b/inst/sql/modified_update/coverage.sql index 84a4c17..9a83f4e 100644 --- a/inst/sql/modified_update/coverage.sql +++ b/inst/sql/modified_update/coverage.sql @@ -2,7 +2,6 @@ SELECT coverage_set, coverage.country, coverage.year, coverage, - gavi_support, target FROM coverage ORDER BY coverage_set, country, year diff --git a/man/modified_update_calculate.Rd b/man/modified_update_calculate.Rd index 26b50bf..4b131c8 100644 --- a/man/modified_update_calculate.Rd +++ b/man/modified_update_calculate.Rd @@ -5,7 +5,7 @@ \title{Do a modified update} \usage{ modified_update_calculate(con, touchstone_name_mod, touchstone_use, - method = 2, version = 1) + method = 2) } \arguments{ \item{con}{Database connection} @@ -18,8 +18,6 @@ this off of} \item{method}{two options: 1 = method1, 2 = method2 method2_v2 is different from method2 in that, it takes per-year-gavi-level as an imput for gavi impact} - -\item{version}{two options: 1 = v1 and 2 = v2} } \description{ Do a modified update