-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathearly_zero.Rd
78 lines (71 loc) · 2.42 KB
/
early_zero.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wlr_weight.R
\name{early_zero}
\alias{early_zero}
\title{Zero early weighting function}
\usage{
early_zero(early_period, fail_rate = NULL)
}
\arguments{
\item{early_period}{The initial delay period where weights increase;
after this, weights are constant at the final weight in the delay period.}
\item{fail_rate}{Failure rate}
}
\value{
A list of parameters of the zero early weighting function
}
\description{
Zero early weighting function
}
\examples{
\dontshow{if (requireNamespace("gsDesign2", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
library(gsDesign2)
# Example 1: Unstratified ----
sim_pw_surv(n = 200) |>
cut_data_by_event(125) |>
wlr(weight = early_zero(early_period = 2))
# Example 2: Stratified ----
n <- 500
# Two strata
stratum <- c("Biomarker-positive", "Biomarker-negative")
prevalence_ratio <- c(0.6, 0.4)
# Enrollment rate
enroll_rate <- define_enroll_rate(
stratum = rep(stratum, each = 2),
duration = c(2, 10, 2, 10),
rate = c(c(1, 4) * prevalence_ratio[1], c(1, 4) * prevalence_ratio[2])
)
enroll_rate$rate <- enroll_rate$rate * n / sum(enroll_rate$duration * enroll_rate$rate)
# Failure rate
med_pos <- 10 # Median of the biomarker positive population
med_neg <- 8 # Median of the biomarker negative population
hr_pos <- c(1, 0.7) # Hazard ratio of the biomarker positive population
hr_neg <- c(1, 0.8) # Hazard ratio of the biomarker negative population
fail_rate <- define_fail_rate(
stratum = rep(stratum, each = 2),
duration = c(3, 1000, 4, 1000),
fail_rate = c(log(2) / c(med_pos, med_pos, med_neg, med_neg)),
hr = c(hr_pos, hr_neg),
dropout_rate = 0.01
)
# Simulate data
temp <- to_sim_pw_surv(fail_rate) # Convert the failure rate
set.seed(2023)
sim_pw_surv(
n = n, # Sample size
# Stratified design with prevalence ratio of 6:4
stratum = data.frame(stratum = stratum, p = prevalence_ratio),
# Randomization ratio
block = c("control", "control", "experimental", "experimental"),
enroll_rate = enroll_rate, # Enrollment rate
fail_rate = temp$fail_rate, # Failure rate
dropout_rate = temp$dropout_rate # Dropout rate
) |>
cut_data_by_event(125) |>
wlr(weight = early_zero(early_period = 2, fail_rate = fail_rate))
\dontshow{\}) # examplesIf}
}
\references{
Xu, Z., Zhen, B., Park, Y., & Zhu, B. (2017).
"Designing therapeutic cancer vaccine trials with delayed treatment effect."
}