The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Advanced Simulation Scenarios

library(simtte)

Exploring the Prognostic Index

The explore_pi_tq_surv() function allows you to understand how the prognostic index (linear predictor) affects survival at a given quantile.

data_sim <- explore_pi_tq_surv(
  pi = seq(-3, 3, by = 0.1),
  mu = -1,
  shape = seq(0.9, 1.1, by = 0.1),
  end_time = 200,
  type = "weibull"
)
head(data_sim)

Visualisation

library(ggplot2)
ggplot(data_sim, aes(x = exp(lp), y = survdiff_tq)) +
  geom_line(aes(color = factor(shape), group = shape)) +
  scale_x_log10() +
  labs(
    x = "Hazard Ratio",
    y = expression(Delta ~ "Survival at" ~ t[50]),
    color = "Shape"
  ) +
  geom_vline(xintercept = 1, linetype = 2) +
  geom_hline(yintercept = 0, linetype = 2) +
  theme_bw()

Custom mrgsolve Models with sim_tte_df

If you have a custom mrgsolve model that outputs a survival probability column, you can use sim_tte_df() directly to perform inverse transform sampling on the output:

# Example with a mock survival data frame (no mrgsolve needed)
set.seed(123)
mrg_output <- data.frame(
  ID = rep(1:5, each = 100),
  time = rep(seq(0.1, 10, length.out = 100), 5),
  p11 = rep(exp(-0.3 * seq(0.1, 10, length.out = 100)), 5)
)
result <- sim_tte_df(mrg_output, surv_var = "p11", id_var = "ID",
  time_var = "time")
head(result)
#> # A tibble: 5 × 3
#>   sim_time sim_status    ID
#>      <dbl>      <dbl> <int>
#> 1      4.2          1     1
#> 2      0.8          1     2
#> 3      3            1     3
#> 4      0.5          1     4
#> 5      0.3          1     5

Multiple Treatment Arms

You can simulate different treatment arms by specifying different prognostic indices:

set.seed(42)
n_per_arm <- 50
times <- seq(0.1, 50, by = 0.1)

# Control arm
lp_ctrl <- matrix(rep(0, n_per_arm), nrow = n_per_arm)
ctrl <- sim_tte(pi = lp_ctrl, mu = -1, coefs = 1.1,
  time = times, type = "weibull", end_time = 50)
ctrl$arm <- "Control"

# Treatment arm (lower hazard)
lp_trt <- matrix(rep(-0.5, n_per_arm), nrow = n_per_arm)
trt <- sim_tte(pi = lp_trt, mu = -1, coefs = 1.1,
  time = times, type = "weibull", end_time = 50)
trt$arm <- "Treatment"

combined <- rbind(ctrl, trt)
head(combined)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.