Skip to content

Commit

Permalink
add new option to functions
Browse files Browse the repository at this point in the history
  • Loading branch information
gfleeming committed Oct 20, 2023
1 parent 0b06ffb commit 94c49a3
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 11 deletions.
10 changes: 8 additions & 2 deletions R/PAFcalc.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
#' @param mort_or_morb Character string - whether the risk functions for conditions with separate mortality and morbidity risk functions
#' should refer to mortality or morbidity. Values could be "mort" or "morb". Default is "mort".
#' @param country Character string - "England" or "Scotland"
#' @param other_lag_function Character - the name of the lag function to use for tobacco related conditions
#' that are not categorised as CVD, COPD, or Cancer. Options: c("Cancers", "CVD", "COPD", "immediate").
#' The default is "Cancers", which gives the most conservative (i.e. slowest) estimate of the rate of decline in
#' the risk of disease after quitting smoking.
#'
#' @return Returns a data.table containing the estimated PAFs.
#'
Expand Down Expand Up @@ -67,7 +71,8 @@ PAFcalc <- function(
tobalc_include_int = FALSE,
within_model = FALSE,
mort_or_morb = c("mort", "morb")[1],
country = c("England", "Scotland")[1]
country = c("England", "Scotland")[1],
other_lag_function = "Cancers"
) {


Expand Down Expand Up @@ -113,7 +118,8 @@ PAFcalc <- function(
show_progress = TRUE,
within_model = within_model,
tobalc_include_int = tobalc_include_int,
country = country)
country = country,
other_lag_function = other_lag_function)

if(y == years[1]) {

Expand Down
13 changes: 10 additions & 3 deletions R/RRFunc.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
#' there is a version that suits the STAPM model by using only the age, sex and IMD quintile variables
#' that are tracked within the STAPM model simulation.
#' @param country Character string - "England" or "Scotland"
#' @param other_lag_function Character - the name of the lag function to use for tobacco related conditions
#' that are not categorised as CVD, COPD, or Cancer. Options: c("Cancers", "CVD", "COPD", "immediate").
#' The default is "Cancers", which gives the most conservative (i.e. slowest) estimate of the rate of decline in
#' the risk of disease after quitting smoking.
#'
#' @return Two data tables are returned:
#' \itemize{
Expand Down Expand Up @@ -224,7 +228,9 @@
#' data = data,
#' substance = "tob",
#' tob_diseases = tob_disease_names,
#' show_progress = TRUE
#' show_progress = TRUE,
#' other_lag_function = "Cancers"
#'
#' )
#'
#'
Expand All @@ -250,7 +256,8 @@ RRFunc <- function(
tobalc_int_data = tobalcepi::tob_alc_risk_int,
show_progress = FALSE,
within_model = TRUE,
country = c("England", "Scotland")[1]
country = c("England", "Scotland")[1],
other_lag_function = "Cancers"
) {


Expand Down Expand Up @@ -712,7 +719,7 @@ RRFunc <- function(
# Matching on the time since quit
data <- merge(
data,
tobalcepi::TobLags(d),
tobalcepi::TobLags(d, other_lag_function = other_lag_function),
by = "time_since_quit", all.x = T, all.y = F, sort = F)

data[is.na(prop_risk_reduction), prop_risk_reduction := 0L]
Expand Down
8 changes: 6 additions & 2 deletions R/TobLags.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@
#'
#'
#' @examples
#'
#' \dontrun{
#' TobLags("Pharynx")
#'
#'
#' TobLags("Low_back_pain", other_lag_function = "immediate")
#' TobLags("Low_back_pain", other_lag_function = "CVD")
#' TobLags("Low_back_pain", other_lag_function = "Cancers")
#'}
TobLags <- function(
disease_name = c("Pharynx", "Oral_cavity"),
n_years = 40,
Expand Down
8 changes: 7 additions & 1 deletion man/PAFcalc.Rd

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

12 changes: 10 additions & 2 deletions man/RRFunc.Rd

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

6 changes: 5 additions & 1 deletion man/TobLags.Rd

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

0 comments on commit 94c49a3

Please sign in to comment.