Skip to content

Commit

Permalink
Remove correct_primary_censoring_bias and call document (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
athowes authored Jul 17, 2024
1 parent e067c3e commit 14a7c86
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 47 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export(calculate_cohort_mean)
export(calculate_truncated_means)
export(combine_obs)
export(construct_cases_by_obs_window)
export(correct_primary_censoring_bias)
export(draws_to_long)
export(drop_zero)
export(epidist)
Expand Down Expand Up @@ -63,6 +62,7 @@ importFrom(checkmate,assert_int)
importFrom(checkmate,assert_names)
importFrom(checkmate,assert_numeric)
importFrom(posterior,as_draws_df)
importFrom(rstan,lookup)
importFrom(stats,as.formula)
importFrom(stats,ecdf)
importFrom(stats,integrate)
Expand Down
14 changes: 0 additions & 14 deletions R/fitting-and-postprocessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,6 @@ extract_lognormal_draws <- function(data, id_vars, from_dt = FALSE) {
return(draws[])
}

#' Primary event bias correction
#'
#' @param draws ...
#' @family postprocess
#' @export
correct_primary_censoring_bias <- function(draws) {
draws <- data.table::copy(draws)
draws[, mean := mean - runif(.N, min = 0, max = 1)]
draws[, meanlog := log(mean^2 / sqrt(sd^2 + mean^2))]
draws[, sdlog := sqrt(log(1 + (sd^2 / mean^2)))]

return(draws[])
}

#' Convert posterior lognormal samples to long format
#'
#' @param draws ...
Expand Down
23 changes: 23 additions & 0 deletions R/globals.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
# Generated by roxyglobals: do not edit by hand

utils::globalVariables(c(
":=", # <sample_model>
"error", # <sample_model>
"no_at_max_treedepth", # <sample_model>
"max_treedepth", # <sample_model>
"per_at_max_treedepth", # <sample_model>
"run_time", # <sample_model>
":=", # <add_natural_scale_mean_sd>
"meanlog", # <add_natural_scale_mean_sd>
"sdlog", # <add_natural_scale_mean_sd>
"sd", # <add_natural_scale_mean_sd>
":=", # <extract_lognormal_draws>
"sdlog", # <extract_lognormal_draws>
"sdlog_log", # <extract_lognormal_draws>
"meanlog", # <extract_lognormal_draws>
"id", # <extract_lognormal_draws>
":=", # <make_relative_to_truth>
"true_value", # <make_relative_to_truth>
"value", # <make_relative_to_truth>
"rel_value", # <make_relative_to_truth>
":=", # <summarise_variable>
"value", # <summarise_variable>
":=", # <as_latent_individual.data.frame>
"id", # <as_latent_individual.data.frame>
".N", # <as_latent_individual.data.frame>
"obs_t", # <as_latent_individual.data.frame>
"obs_at", # <as_latent_individual.data.frame>
"ptime_lwr", # <as_latent_individual.data.frame>
Expand All @@ -31,6 +38,7 @@ utils::globalVariables(c(
"row_id", # <as_latent_individual.data.frame>
"woverlap", # <epidist_stancode.epidist_latent_individual>
"row_id", # <epidist_stancode.epidist_latent_individual>
":=", # <observe_process>
"ptime_daily", # <observe_process>
"ptime", # <observe_process>
"ptime_lwr", # <observe_process>
Expand All @@ -43,21 +51,25 @@ utils::globalVariables(c(
"delay_lwr", # <observe_process>
"delay_upr", # <observe_process>
"obs_at", # <observe_process>
":=", # <filter_obs_by_obs_time>
"obs_at", # <filter_obs_by_obs_time>
"ptime", # <filter_obs_by_obs_time>
"censored_obs_time", # <filter_obs_by_obs_time>
"ptime_lwr", # <filter_obs_by_obs_time>
"censored", # <filter_obs_by_obs_time>
"stime_upr", # <filter_obs_by_obs_time>
":=", # <filter_obs_by_ptime>
"censored", # <filter_obs_by_ptime>
"ptime_upr", # <filter_obs_by_ptime>
"stime_upr", # <filter_obs_by_ptime>
"ptime", # <filter_obs_by_ptime>
"censored_obs_time", # <filter_obs_by_ptime>
"ptime_lwr", # <filter_obs_by_ptime>
"censored_obs_time", # <pad_zero>
":=", # <pad_zero>
"delay_lwr", # <pad_zero>
"delay_daily", # <pad_zero>
":=", # <plot_relative_recovery>
"value", # <plot_relative_recovery>
"rel_value", # <plot_relative_recovery>
"case_type", # <plot_cases_by_obs_window>
Expand All @@ -73,15 +85,23 @@ utils::globalVariables(c(
"ptime_daily", # <plot_mean_posterior_pred>
"n", # <plot_mean_posterior_pred>
"obs_horizon", # <plot_mean_posterior_pred>
".data", # <plot_mean_posterior_pred>
":=", # <linelist_to_counts>
"time", # <linelist_to_counts>
".N", # <linelist_to_counts>
":=", # <linelist_to_cases>
"primary", # <linelist_to_cases>
"secondary", # <linelist_to_cases>
":=", # <reverse_obs_at>
"obs_at", # <reverse_obs_at>
"stime", # <construct_cases_by_obs_window>
"ptime", # <construct_cases_by_obs_window>
":=", # <construct_cases_by_obs_window>
"case_type", # <construct_cases_by_obs_window>
":=", # <combine_obs>
"obs_at", # <combine_obs>
"stime_daily", # <combine_obs>
":=", # <calculate_censor_delay>
"ptime_delay", # <calculate_censor_delay>
"ptime", # <calculate_censor_delay>
"ptime_daily", # <calculate_censor_delay>
Expand All @@ -91,9 +111,12 @@ utils::globalVariables(c(
"stime_delay", # <calculate_censor_delay>
"stime", # <calculate_censor_delay>
"stime_daily", # <calculate_censor_delay>
".N", # <event_to_incidence>
"ptime_daily", # <event_to_incidence>
"rlnorm", # <simulate_secondary>
":=", # <simulate_secondary>
"delay", # <simulate_secondary>
".N", # <simulate_secondary>
"stime", # <simulate_secondary>
"ptime", # <simulate_secondary>
NULL
Expand Down
1 change: 0 additions & 1 deletion man/add_natural_scale_mean_sd.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 0 additions & 25 deletions man/correct_primary_censoring_bias.Rd

This file was deleted.

1 change: 0 additions & 1 deletion man/draws_to_long.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/extract_lognormal_draws.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/make_relative_to_truth.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/sample_model.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/summarise_draws.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/summarise_variable.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 14a7c86

Please sign in to comment.