Skip to content

Commit

Permalink
refac: updated dates to agree with new dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsantiagoquevedo committed Nov 24, 2024
1 parent de630f3 commit 758e7aa
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion R/estimate_vaccineff.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#' vaccinated_status = "v",
#' unvaccinated_status = "u",
#' immunization_delay = 15,
#' end_cohort = as.Date("2044-12-31"),
#' end_cohort = as.Date("2021-12-31"),
#' match = TRUE,
#' exact = c("age", "sex"),
#' nearest = NULL
Expand Down
2 changes: 1 addition & 1 deletion R/make_vaccineff_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#' vaccinated_status = "v",
#' unvaccinated_status = "u",
#' immunization_delay = 15,
#' end_cohort = as.Date("2044-12-31"),
#' end_cohort = as.Date("2021-12-31"),
#' match = TRUE,
#' exact = c("age", "sex"),
#' nearest = NULL
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ vaccineff_data <- make_vaccineff_data(
vaccinated_status = "v",
unvaccinated_status = "u",
immunization_delay = 15,
end_cohort = as.Date("2044-12-31"),
end_cohort = as.Date("2021-12-31"),
match = TRUE,
exact = "sex",
nearest = c(age = 1)
Expand Down
18 changes: 9 additions & 9 deletions tests/testthat/_snaps/coh_immunization.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
Code
head(immunization_dose, 20)
Output
[1] NA NA NA NA
[5] NA "vaccine_date_2" NA NA
[9] "vaccine_date_2" "vaccine_date_2" NA "vaccine_date_2"
[13] NA NA NA NA
[17] NA "vaccine_date_2" "vaccine_date_2" "vaccine_date_2"
[1] NA NA NA "vaccine_date_2"
[5] "vaccine_date_2" "vaccine_date_2" NA "vaccine_date_2"
[9] NA NA NA "vaccine_date_2"
[13] "vaccine_date_2" "vaccine_date_2" "vaccine_date_2" "vaccine_date_2"
[17] "vaccine_date_2" "vaccine_date_2" "vaccine_date_2" "vaccine_date_2"

# `immunization_vaccine`: Basic expectations

Code
head(which_vaccine, 30)
Output
[1] NA NA NA NA NA "BRAND1" NA NA
[9] "BRAND1" "BRAND1" NA "BRAND2" NA NA NA NA
[17] NA "BRAND2" "BRAND1" "BRAND2" NA "BRAND1" NA NA
[25] NA NA "BRAND2" NA NA NA
[1] NA NA NA "BRAND2" "BRAND1" "BRAND2" NA "BRAND2"
[9] NA NA NA "BRAND1" "BRAND1" "BRAND2" "BRAND2" "BRAND2"
[17] "BRAND1" "BRAND1" "BRAND1" "BRAND1" "BRAND2" "BRAND2" NA NA
[25] "BRAND2" "BRAND1" "BRAND2" NA NA "BRAND2"

16 changes: 8 additions & 8 deletions tests/testthat/_snaps/coh_match.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
{
"type": "double",
"attributes": {},
"value": [30.18416801, 0.5088853, 0.4911147]
"value": [63.23626374, 0.52197802, 0.47802198]
},
{
"type": "double",
"attributes": {},
"value": [47.51706037, 0.54855643, 0.45144357]
"value": [63.66823899, 0.59748428, 0.40251572]
},
{
"type": "double",
"attributes": {},
"value": [0.87245622, 0.0795363, -0.0795363]
"value": [0.03984279, 0.15254353, -0.15254353]
}
]
}
Expand Down Expand Up @@ -85,17 +85,17 @@
{
"type": "double",
"attributes": {},
"value": [42.55192878, 0.54599407, 0.45400593]
"value": [63.2005571, 0.52089136, 0.47910864]
},
{
"type": "double",
"attributes": {},
"value": [44.90801187, 0.54599407, 0.45400593]
"value": [63.54038997, 0.52089136, 0.47910864]
},
{
"type": "double",
"attributes": {},
"value": [0.12717971, 0, 0]
"value": [0.03161695, 0, 0]
}
]
}
Expand Down Expand Up @@ -137,12 +137,12 @@
{
"type": "integer",
"attributes": {},
"value": [619, 337, 282]
"value": [364, 359, 5]
},
{
"type": "integer",
"attributes": {},
"value": [381, 337, 44]
"value": [636, 359, 277]
}
]
}
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/_snaps/coh_match_utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
summary
Output
u v
All 619 381
Matched 337 337
Unmatched 282 44
All 364 636
Matched 359 359
Unmatched 5 277

4 changes: 2 additions & 2 deletions tests/testthat/_snaps/coh_time_to_event.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
Code
head(exposition_time, 20)
Output
[1] 280 280 162 171 169 280 280 37 280 280 280 280 280 280 280 280 171 213 280
[20] 98
[1] 152 161 167 224 221 242 281 183 281 250 165 281 194 281 123 225 281 281 281
[20] 281

2 changes: 1 addition & 1 deletion tests/testthat/test-coh_eff_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ vaccineff_data <- make_vaccineff_data(
vaccinated_status = "v",
unvaccinated_status = "u",
immunization_delay = 15,
end_cohort = as.Date("2044-12-31"),
end_cohort = as.Date("2021-12-31"),
match = FALSE
)

Expand Down
14 changes: 7 additions & 7 deletions tests/testthat/test-coh_immunization.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#### Tests for coh_immunization.R module ####
#### Prepare data for all the tests ####
data("cohortdata")
start_cohort <- as.Date("2044-01-01")
end_cohort <- as.Date("2044-12-31")
start_cohort <- as.Date("2021-01-01")
end_cohort <- as.Date("2021-12-31")
# calculate immunization date
cohortdata$immunization <- get_immunization_date(
data_set = cohortdata,
outcome_date_col = "death_date",
censoring_date_col = "death_other_causes",
immunization_delay = 14,
vacc_date_col = c("vaccine_date_1", "vaccine_date_2"),
end_cohort = as.Date("2044-12-31"),
end_cohort = as.Date("2021-12-31"),
take_first = FALSE
)

Expand Down Expand Up @@ -103,7 +103,7 @@ test_that("`make_immunization`: vaccine names provided", {
test_that("`get_immunization_date`: Basic expectations", {
# get immunization dates
vacc_date_col <- c("vaccine_date_1", "vaccine_date_2")
tf <- as.Date("2044-12-31")
tf <- as.Date("2021-12-31")
immunization_delay <- 45 # use extreme outcome delay to test expectations
limit_delta <- immunization_delay
cohortdata$immunization <- get_immunization_date(
Expand Down Expand Up @@ -208,7 +208,7 @@ test_that("`get_immunization_date`: Basic expectations", {
test_that("`get_immunization_date`: Take first vaccination", {
# get immunization dates
vacc_date_col <- c("vaccine_date_1", "vaccine_date_2")
tf <- as.Date("2044-12-31")
tf <- as.Date("2021-12-31")
immunization_delay <- 45 # use extreme outcome delay to test expectations
limit_delta <- immunization_delay
cohortdata$immunization <- get_immunization_date(
Expand Down Expand Up @@ -273,8 +273,8 @@ test_that("`get_immunization_date`: Take first vaccination", {
# Test coherence immunization date and end_cohort date
test_that("`get_immunization_date`: end_cohort > immunization", {
date_format <- "%Y-%m-%d"
t0 <- as.Date("2044-01-01", date_format)
tf <- as.Date("2044-12-31", date_format)
t0 <- as.Date("2021-01-01", date_format)
tf <- as.Date("2021-12-31", date_format)
immunization_delay <- 14
data(cohortdata)

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-coh_match.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#### Tests for coh_match.R module ####
#### Prepare data for all the tests ####
data("cohortdata")
start_cohort <- as.Date("2044-01-01")
end_cohort <- as.Date("2044-12-31")
start_cohort <- as.Date("2021-01-01")
end_cohort <- as.Date("2021-12-31")

# Sample cohort to make tests faster - take a bigger sample
sample_size <- 1000
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-coh_match_iterate.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#### Tests for coh_match_iterate.R module ####
#### Prepare data for all the tests ####
data("cohortdata")
start_cohort <- as.Date("2044-01-01")
end_cohort <- as.Date("2044-12-31")
start_cohort <- as.Date("2021-01-01")
end_cohort <- as.Date("2021-12-31")

# sample cohort to make tests faster - take a bigger sample
sample_size <- 10000
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-coh_match_utils.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#### Tests for coh_match_utils.R module ####
#### Prepare data for all tests ####
data("cohortdata")
start_cohort <- as.Date("2044-01-01")
end_cohort <- as.Date("2044-12-31")
start_cohort <- as.Date("2021-01-01")
end_cohort <- as.Date("2021-12-31")

# tests for match_cohort_() and match_summary can use the small data
sample_size <- 1000
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-coh_time_to_event.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#### Tests for coh_time_to_event.R module ####
#### Prepare data for all the tests ####
data("cohortdata")
end_cohort <- as.Date("2044-12-31")
end_cohort <- as.Date("2021-12-31")

# sample cohort to make tests faster - take a bigger sample
sample_size <- 10000
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-estimate_vaccineff.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ vaccineff_data <- make_vaccineff_data(
vaccinated_status = "v",
unvaccinated_status = "u",
immunization_delay = 15,
end_cohort = as.Date("2044-12-31"),
end_cohort = as.Date("2021-12-31"),
match = TRUE,
exact = c("age", "sex"),
nearest = NULL
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-handler_validations.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ vacc_name_col <- "vaccine_2"
vaccinated_status <- "v"
unvaccinated_status <- "u"
immunization_delay <- 0
start_cohort <- as.Date("2044-01-31")
end_cohort <- as.Date("2044-12-31")
start_cohort <- as.Date("2021-01-31")
end_cohort <- as.Date("2021-12-31")
match <- NULL
nearest <- NULL
exact <- NULL
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-utils_coverage.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ vaccineff_data <- make_vaccineff_data(
vaccinated_status = "1 vacc",
unvaccinated_status = "0 unvacc",
immunization_delay = 15,
end_cohort = as.Date("2044-12-31"),
end_cohort = as.Date("2021-12-31"),
match = TRUE,
exact = c("age", "sex"),
nearest = NULL
Expand Down
6 changes: 3 additions & 3 deletions vignettes/cohort_design.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ vaccineff_data <- make_vaccineff_data(
vaccinated_status = "v",
unvaccinated_status = "u",
immunization_delay = 15,
end_cohort = as.Date("2044-12-31"),
end_cohort = as.Date("2021-12-31"),
match = FALSE
)
Expand Down Expand Up @@ -111,7 +111,7 @@ vaccineff_data_matched <- make_vaccineff_data(
vaccinated_status = "v",
unvaccinated_status = "u",
immunization_delay = 15,
end_cohort = as.Date("2044-12-31"),
end_cohort = as.Date("2021-12-31"),
match = TRUE,
exact = c("age", "sex"),
nearest = NULL
Expand Down Expand Up @@ -158,7 +158,7 @@ vaccineff_data_matched2 <- make_vaccineff_data(
vaccinated_status = "v",
unvaccinated_status = "u",
immunization_delay = 15,
end_cohort = as.Date("2044-12-31"),
end_cohort = as.Date("2021-12-31"),
match = TRUE,
exact = "sex",
nearest = c(age = 2)
Expand Down
2 changes: 1 addition & 1 deletion vignettes/vaccineff.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ vaccineff_data <- make_vaccineff_data(
vaccinated_status = "v",
unvaccinated_status = "u",
immunization_delay = 15,
end_cohort = as.Date("2044-12-31"),
end_cohort = as.Date("2021-12-31"),
match = TRUE,
exact = c("age", "sex"),
nearest = NULL
Expand Down

0 comments on commit 758e7aa

Please sign in to comment.