Skip to content

Commit

Permalink
remove unused fn and move fn
Browse files Browse the repository at this point in the history
  • Loading branch information
hillalex committed Jul 14, 2024
1 parent 06304b0 commit 692f908
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 33 deletions.
13 changes: 0 additions & 13 deletions R/adjust.R

This file was deleted.

16 changes: 14 additions & 2 deletions R/scova.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ scova <- R6::R6Class(

if (length(private$all_formula_vars) > 0) {
logger::log_info("Adjusting by regression coefficients")
dt_samples_wide <- adjust_parameters(dt_samples_wide)
dt_samples_wide <- private$adjust_parameters(dt_samples_wide)
}

# adding artificial ids so that we can do a big merge, adding times to
Expand Down Expand Up @@ -230,7 +230,7 @@ scova <- R6::R6Class(
data.table::setcolorder(dt_proc, c("k", "p", ".draw"))

if (length(private$all_formula_vars) > 0) {
return(adjust_parameters(dt_proc))
return(private$adjust_parameters(dt_proc))
} else {
return(dt_proc)
}
Expand All @@ -257,6 +257,18 @@ scova <- R6::R6Class(
data.table::setnames(dt_out, c("n", "k", ".draw"), c("stan_id", "titre_type", "draw"))

dt_out
},
adjust_parameters <- function(dt) {
params_to_adjust <- c(
"t0_pop", "tp_pop", "ts_pop", "m1_pop", "m2_pop", "m3_pop")
# Loop through the parameters you want to adjust
for (param in params_to_adjust) {
# Remove the '_pop' suffix to construct the beta variable name
beta_var <- paste0("beta_", gsub("_pop$", "", param))
dt[, (param) := get(param) + get(beta_var)]
}

return(dt)
}
),
public = list(
Expand Down
18 changes: 0 additions & 18 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,3 @@ summarise_draws <- function(dt_in, column_name, by = by) {
by = by
]
}

summarise_individual_trajectories <- function(trajectories) {

# Declare variables to suppress notes when compiling package
# https://github.com/Rdatatable/data.table/issues/850#issuecomment-259466153
mu <- calendar_date <- draw <- titre_type <- NULL

dt_trajectories_mean <- trajectories[
!is.nan(mu), .(pop_mu_sum = mean(mosaic::resample(mu))),
by = .(calendar_date, draw, titre_type)]

dt_trajectories_mean_sum <- summarise_draws(
dt_trajectories_mean,
column_name = "pop_mu_sum",
by = c("calendar_date", "titre_type"))

convert_log_scale_inverse(dt_trajectories_mean_sum)
}

0 comments on commit 692f908

Please sign in to comment.