Skip to content

Commit d8b4ae9

Browse files
committed
Fixed issue/bug with logistic dropout mechanism
1 parent e0ed8be commit d8b4ae9

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

R/swtrial_inf.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
swtrial_inf <- function(repn, k, i = 8, j = 5, intervention_seq = 4, deltas, betas, family, sigma_epsilon = 0.0, sigma_alpha = 0.0, sigma_gamma = 0.0, sigma_phi = 0.0, lambda = 0.05, p = 2, nu = 0.0, omega1 = 0.0, omega2 = 0.0, omega3 = 0.0, logistic_dropout = FALSE, logistic_intercept = -2) {
8181
# repn <- 1
8282
# k <- 10
83-
# i <- 8
83+
# i <- 32
8484
# j <- 5
8585
# intervention_seq <- 4
8686
# deltas <- rep(5, 4)
@@ -93,9 +93,9 @@ swtrial_inf <- function(repn, k, i = 8, j = 5, intervention_seq = 4, deltas, bet
9393
# lambda <- exp(-1.5)
9494
# p <- 1.0
9595
# nu <- -0.2
96-
# omega1 <- log(0.9)
96+
# omega1 <- -0.105
9797
# omega2 <- 0.0
98-
# omega3 <- log(0.9)
98+
# omega3 <- -0.105
9999
# logistic_dropout <- TRUE
100100
# logistic_intercept <- -2
101101

@@ -156,7 +156,10 @@ swtrial_inf <- function(repn, k, i = 8, j = 5, intervention_seq = 4, deltas, bet
156156
logdf$u <- stats::runif(n = nrow(logdf))
157157
logdf <- dplyr::filter(logdf, status <= 1)
158158
logdf <- dplyr::mutate(logdf, eventtime = (j - 1) + u)
159-
logdf <- dplyr::summarise(logdf, eventtime = max(eventtime))
159+
logdf <- dplyr::filter(logdf, eventtime == max(eventtime)) |>
160+
dplyr::select(id, status, eventtime) |>
161+
dplyr::mutate(eventtime = ifelse(status == 1, eventtime, ceiling(eventtime) + 1)) |>
162+
dplyr::select(-status)
160163
# Merge back drop-out information and censor trajectories
161164
df <- dplyr::left_join(df, logdf, by = "id")
162165
df <- dplyr::mutate(df, yobs = ifelse(j <= eventtime, y, NA))

0 commit comments

Comments
 (0)