From 2d0b379c12995f0538065cd5062c9bc2ac5355b8 Mon Sep 17 00:00:00 2001 From: Adam Howes Date: Fri, 13 Sep 2024 15:49:37 +0100 Subject: [PATCH] Issue #320: Rename delay central (#325) * Rename delay_central as delay * Run document --- R/globals.R | 2 +- R/latent_individual.R | 8 ++++---- tests/testthat/test-latent_individual.R | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/R/globals.R b/R/globals.R index ace04826a..d7a6f93b9 100644 --- a/R/globals.R +++ b/R/globals.R @@ -15,7 +15,7 @@ utils::globalVariables(c( "stime_upr", # "woverlap", # "swindow", # - "delay_central", # + "delay", # "row_id", # "woverlap", # "row_id", # diff --git a/R/latent_individual.R b/R/latent_individual.R index 134e59321..d065c4fbd 100644 --- a/R/latent_individual.R +++ b/R/latent_individual.R @@ -56,7 +56,7 @@ as_latent_individual.data.frame <- function(data) { )] data[, woverlap := as.numeric(stime_lwr < ptime_upr)] data[, swindow := stime_upr - stime_lwr] - data[, delay_central := stime_lwr - ptime_lwr] + data[, delay := stime_lwr - ptime_lwr] data[, row_id := seq_len(.N)] if (nrow(data) > 1) { data <- data[, id := as.factor(id)] @@ -86,7 +86,7 @@ epidist_validate.epidist_latent_individual <- function(data) { must.include = c("case", "ptime_lwr", "ptime_upr", "stime_lwr", "stime_upr", "obs_at", "id", "obs_t", "pwindow", "woverlap", - "swindow", "delay_central", "row_id") + "swindow", "delay", "row_id") ) if (nrow(data) > 1) { checkmate::assert_factor(data$id) @@ -95,7 +95,7 @@ epidist_validate.epidist_latent_individual <- function(data) { checkmate::assert_numeric(data$pwindow, lower = 0) checkmate::assert_numeric(data$woverlap, lower = 0) checkmate::assert_numeric(data$swindow, lower = 0) - checkmate::assert_numeric(data$delay_central, lower = 0) + checkmate::assert_numeric(data$delay, lower = 0) checkmate::assert_integer(data$row_id, lower = 0) } @@ -157,7 +157,7 @@ epidist_formula.epidist_latent_individual <- function(data, family, formula, formula <- brms:::validate_formula(formula, data = data, family = family) formula <- stats::update( - formula, delay_central | vreal(obs_t, pwindow, swindow) ~ . + formula, delay | vreal(obs_t, pwindow, swindow) ~ . ) # Using this here for checking purposes diff --git a/tests/testthat/test-latent_individual.R b/tests/testthat/test-latent_individual.R index f6ac673fb..5f7a55da6 100644 --- a/tests/testthat/test-latent_individual.R +++ b/tests/testthat/test-latent_individual.R @@ -84,7 +84,7 @@ test_that("epidist_formula.epidist_latent_individual with default settings produ expect_s3_class(form, "brmsformula") expect_equal( as_string_formula(form$formula), - "delay_central | vreal(obs_t, pwindow, swindow) ~ 1" + "delay | vreal(obs_t, pwindow, swindow) ~ 1" ) expect_equal( as_string_formula(form$pforms$sigma), @@ -102,7 +102,7 @@ test_that("epidist_formula.epidist_latent_individual with custom formulas produc expect_s3_class(form_sex, "brmsformula") expect_equal( as_string_formula(form_sex$formula), - "delay_central | vreal(obs_t, pwindow, swindow) ~ sex" + "delay | vreal(obs_t, pwindow, swindow) ~ sex" ) expect_equal( as_string_formula(form_sex$pforms$sigma),