library(tibble)
library(dplyr)
library(gt)
library(testthat)
devtools::load_all()

Test 1

x1 <- gs_power_ahr() 
x2 <- gs_power_ahr_() 
tibble(version = c(rep("new", 3), rep("old", 3)),
       analysis = rep(1:3, 2),
       samplesize = c(x1$analysis$N, rep(NA, 3)),
       events = c(x1$analysis$Events, x2$Events[1:3]),
       time = c(x1$analysis$Time, x2$Time[1:3]),
       theta = c(x1$analysis$theta, x2$theta[1:3]),
       Z_upper = c((x1$bounds %>% filter(Bound == "Upper"))$Z, (x2 %>% filter(Bound == "Upper"))$Z),
       Z_lower = c((x1$bounds %>% filter(Bound == "Lower"))$Z, (x2 %>% filter(Bound == "Lower"))$Z),
       prob_upper = c((x1$bounds %>% filter(Bound == "Upper"))$Probability, (x2 %>% filter(Bound == "Upper"))$Probability),
       prob_lower = c((x1$bounds %>% filter(Bound == "Lower"))$Probability, (x2 %>% filter(Bound == "Lower"))$Probability),
       AHR = c(x1$analysis$AHR, x2$AHR[1:3]),
       info = c(x1$analysis$info, x2$info[1:3]),
       info0 = c(x1$analysis$info0, x2$info0[1:3])
       ) %>% 
  arrange(analysis) %>% 
  group_by(analysis) %>% 
  gt() %>% 
  tab_style(
    style = list(cell_fill(color = "#d3edeb")),
    locations = cells_body(rows = `version` == "old"))

Test 2

x1 <- gs_power_ahr(analysisTimes = c(12, 24, 36),
                   events = NULL,
                   binding = TRUE,
                   upper = gs_spending_bound,
                   upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL),
                   lower = gs_spending_bound,
                   lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL))

x2 <- gs_power_ahr_(analysisTimes = c(12, 24, 36),
                   events = NULL,
                   binding = TRUE,
                   upper = gs_spending_bound,
                   upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL),
                   lower = gs_spending_bound,
                   lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL))
tibble(version = c(rep("new", 3), rep("old", 3)),
       analysis = rep(1:3, 2),
       samplesize = c(x1$analysis$N, rep(NA, 3)),
       events = c(x1$analysis$Events, x2$Events[1:3]),
       time = c(x1$analysis$Time, x2$Time[1:3]),
       theta = c(x1$analysis$theta, x2$theta[1:3]),
       Z_upper = c((x1$bounds %>% filter(Bound == "Upper"))$Z, (x2 %>% filter(Bound == "Upper"))$Z),
       Z_lower = c((x1$bounds %>% filter(Bound == "Lower"))$Z, (x2 %>% filter(Bound == "Lower"))$Z),
       prob_upper = c((x1$bounds %>% filter(Bound == "Upper"))$Probability, (x2 %>% filter(Bound == "Upper"))$Probability),
       prob_lower = c((x1$bounds %>% filter(Bound == "Lower"))$Probability,  (x2 %>% filter(Bound == "Lower"))$Probability),
       AHR = c(x1$analysis$AHR, x2$AHR[1:3]),
       info = c(x1$analysis$info, x2$info[1:3]),
       info0 = c(x1$analysis$info0, x2$info0[1:3])
       ) %>% 
  arrange(analysis) %>% 
  group_by(analysis) %>% 
  gt() %>% 
  tab_style(
    style = list(cell_fill(color = "#d3edeb")),
    locations = cells_body(rows = `version` == "old"))

Test 3

x1 <- gs_power_ahr(analysisTimes = NULL,
                   events = c(20, 50, 70),
                   binding = TRUE,
                   upper = gs_spending_bound,
                   upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL),
                   lower = gs_spending_bound,
                   lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL))

x2 <- gs_power_ahr_(analysisTimes = NULL,
                   events = c(20, 50, 70),
                   binding = TRUE,
                   upper = gs_spending_bound,
                   upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL),
                   lower = gs_spending_bound,
                   lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL))
tibble(version = c(rep("new", 3), rep("old", 3)),
       analysis = rep(1:3, 2),
       samplesize = c(x1$analysis$N, rep(NA, 3)),
       events = c(x1$analysis$Events, x2$Events[1:3]),
       time = c(x1$analysis$Time, x2$Time[1:3]),
       theta = c(x1$analysis$theta, x2$theta[1:3]),
       Z_upper = c((x1$bounds %>% filter(Bound == "Upper"))$Z, (x2 %>% filter(Bound == "Upper"))$Z),
       Z_lower = c((x1$bounds %>% filter(Bound == "Lower"))$Z, (x2 %>% filter(Bound == "Lower"))$Z),
       prob_upper = c((x1$bounds %>% filter(Bound == "Upper"))$Probability, (x2 %>% filter(Bound == "Upper"))$Probability),
       prob_lower = c((x1$bounds %>% filter(Bound == "Lower"))$Probability,  (x2 %>% filter(Bound == "Lower"))$Probability),
       AHR = c(x1$analysis$AHR, x2$AHR[1:3]),
       info = c(x1$analysis$info, x2$info[1:3]),
       info0 = c(x1$analysis$info0, x2$info0[1:3])
       ) %>% 
  arrange(analysis) %>% 
  group_by(analysis) %>% 
  gt() %>% 
  tab_style(
    style = list(cell_fill(color = "#d3edeb")),
    locations = cells_body(rows = `version` == "old"))

Test 4

x1 <- gs_power_ahr(analysisTimes = c(12, 24, 36),
                   events = c(30, 40, 50),
                   binding = TRUE,
                   upper = gs_spending_bound,
                   upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL),
                   lower = gs_spending_bound,
                   lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL))

x2 <- gs_power_ahr_(analysisTimes = c(12, 24, 36),
                   events = c(30, 40, 50),
                   binding = TRUE,
                   upper = gs_spending_bound,
                   upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL),
                   lower = gs_spending_bound,
                   lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL))
tibble(version = c(rep("new", 3), rep("old", 3)),
       analysis = rep(1:3, 2),
       samplesize = c(x1$analysis$N, rep(NA, 3)),
       events = c(x1$analysis$Events, x2$Events[1:3]),
       time = c(x1$analysis$Time, x2$Time[1:3]),
       theta = c(x1$analysis$theta, x2$theta[1:3]),
       Z_upper = c((x1$bounds %>% filter(Bound == "Upper"))$Z, (x2 %>% filter(Bound == "Upper"))$Z),
       Z_lower = c((x1$bounds %>% filter(Bound == "Lower"))$Z, (x2 %>% filter(Bound == "Lower"))$Z),
       prob_upper = c((x1$bounds %>% filter(Bound == "Upper"))$Probability, (x2 %>% filter(Bound == "Upper"))$Probability),
       prob_lower = c((x1$bounds %>% filter(Bound == "Lower"))$Probability,  (x2 %>% filter(Bound == "Lower"))$Probability),
       AHR = c(x1$analysis$AHR, x2$AHR[1:3]),
       info = c(x1$analysis$info, x2$info[1:3]),
       info0 = c(x1$analysis$info0, x2$info0[1:3])
       ) %>% 
  arrange(analysis) %>% 
  group_by(analysis) %>% 
  gt() %>% 
  tab_style(
    style = list(cell_fill(color = "#d3edeb")),
    locations = cells_body(rows = `version` == "old"))


keaven/gsDesign2 documentation built on Oct. 13, 2022, 8:42 p.m.