From ea020987989f78b855bc3ab7b127b63f414360a4 Mon Sep 17 00:00:00 2001 From: Robin Denz Date: Wed, 28 Feb 2024 09:15:34 +0100 Subject: [PATCH] fix: resolves issue #3 --- NEWS.md | 1 + R/node_time_to_event.r | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index f308e85..e955d28 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,3 +8,4 @@ * dag2matrix() now returns a numeric matrix even if the dag object contains only root nodes * node() and node_td() now support character vectors in the 'name' argument, allowing easy creation of multiple nodes with the same definition * Add sim_n_datasets() function +* Fix Bug in node_time_to_event() function that lead to the `immunity_duration` parameter being used incorrectly diff --git a/R/node_time_to_event.r b/R/node_time_to_event.r index 0d1a4cf..60ba5b9 100644 --- a/R/node_time_to_event.r +++ b/R/node_time_to_event.r @@ -47,8 +47,7 @@ node_time_to_event <- function(data, parents, sim_time, name, event_prob <- fifelse(is.na(data[[name_time]]), event_prob, fifelse(data[[name_event]] & days_since_event < event_duration, 1, - fifelse(data[[name_event]] & - days_since_event < immunity_duration, 0, + fifelse(days_since_event < immunity_duration, 0, event_prob))) # draw new events based on this probability