Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #536: Setting the threshold to Inf message #537

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions R/marginal_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
data, obs_time_threshold = 2, weight = NULL, ...) {
assert_epidist.epidist_linelist_data(data)

data <- data |>

Check warning on line 68 in R/marginal_model.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/marginal_model.R,line=68,col=11,[one_call_pipe_linter] Avoid pipe |> for expressions with only a single call.
mutate(
pwindow = .data$ptime_upr - .data$ptime_lwr,
swindow = .data$stime_upr - .data$stime_lwr,
Expand All @@ -87,11 +87,11 @@
if (n_beyond > 0) {
cli::cli_inform(c(
"!" = paste0(
"Setting {n_beyond} observation time{?s} beyond ",
"{threshold} (={obs_time_threshold}x max delay) to Inf. ",
"This improves model efficiency by reducing unique observation times ",
"while maintaining model accuracy as these times should have ",
"negligible impact."
"{n_beyond} relative observation time{?s} beyond {threshold} ",
"(= {obs_time_threshold} x max delay) set to Inf ",
"See {.var obs_time_threshold}. This improves efficiency by ",
"reducing unique data points. Impact on accuracy is neglible ",
"if right truncation bias for these data points is limited."
)
))
data$relative_obs_time[data$relative_obs_time > threshold] <- Inf
Expand Down Expand Up @@ -145,7 +145,7 @@
#' @export
new_epidist_marginal_model <- function(data) {
class(data) <- c("epidist_marginal_model", class(data))
return(data)

Check warning on line 148 in R/marginal_model.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/marginal_model.R,line=148,col=3,[return_linter] Use implicit return behavior; explicit return() is not needed.
}

#' @method assert_epidist epidist_marginal_model
Expand All @@ -170,7 +170,7 @@
)
}
assert_numeric(data$n, lower = 1)
return(invisible(NULL))

Check warning on line 173 in R/marginal_model.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/marginal_model.R,line=173,col=3,[return_linter] Use implicit return behavior; explicit return() is not needed.
}

#' Check if data has the `epidist_marginal_model` class
Expand All @@ -179,7 +179,7 @@
#' @family marginal_model
#' @export
is_epidist_marginal_model <- function(data) {
return(inherits(data, "epidist_marginal_model"))

Check warning on line 182 in R/marginal_model.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/marginal_model.R,line=182,col=3,[return_linter] Use implicit return behavior; explicit return() is not needed.
}

#' Create the model-specific component of an `epidist` custom family
Expand Down Expand Up @@ -208,7 +208,7 @@
posterior_predict = epidist_gen_posterior_predict(family),
posterior_epred = epidist_gen_posterior_epred(family)
)
return(custom_family)

Check warning on line 211 in R/marginal_model.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/marginal_model.R,line=211,col=3,[return_linter] Use implicit return behavior; explicit return() is not needed.
}

#' Define the model-specific component of an `epidist` custom formula for the
Expand All @@ -228,7 +228,7 @@
formula, delay_lwr | weights(n) +
vreal(relative_obs_time, pwindow, swindow, delay_upr) ~ .
)
return(formula)

Check warning on line 231 in R/marginal_model.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/marginal_model.R,line=231,col=3,[return_linter] Use implicit return behavior; explicit return() is not needed.
}

#' Transform data for the marginal model
Expand Down Expand Up @@ -261,7 +261,7 @@

.inform_data_summarised(data, trans_data, c(required_cols))

return(trans_data)

Check warning on line 264 in R/marginal_model.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/marginal_model.R,line=264,col=3,[return_linter] Use implicit return behavior; explicit return() is not needed.
}

#' @method epidist_stancode epidist_marginal_model
Expand Down Expand Up @@ -289,7 +289,7 @@
fixed = TRUE
)

if (family_name == "lognormal") {

Check warning on line 292 in R/marginal_model.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/marginal_model.R,line=292,col=3,[if_switch_linter] Prefer switch() statements over repeated if/else equality tests, e.g., switch(x, a = 1, b = 2) over if (x == "a") 1 else if (x == "b") 2.
dist_id <- 1
} else if (family_name == "gamma") {
dist_id <- 2
Expand Down Expand Up @@ -341,7 +341,7 @@
}

.marginal_required_cols <- function() {
return(c(

Check warning on line 344 in R/marginal_model.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/marginal_model.R,line=344,col=3,[return_linter] Use implicit return behavior; explicit return() is not needed.
"delay_lwr", "delay_upr", "relative_obs_time", "pwindow", "swindow", "n"
))
}
Loading