Set up time-to-events
set_event.RdDefines the model formula and distribution to be used when simulating time-to-events. Please see the user-guide for the model formulations
Arguments
- event
Distribution of time-to-events:
event = "pwexp"for piece-wise exponential distribution.event = "weibull"for Weibull distribution- lambdaC
Baseline hazard rate of internal control arm. Specify a vector for piece-wise hazard with duration specified in
t_itvifevent = "pwexp"- beta
covariates' coefficients (i.e. log hazard ratios). Must be equal in length to the number of covariates created by
simu_cov()(or less if restricted bykeep) plus the number of covariates defined bychange.- shape
the shape parameter of Weibull distribution if
event = "weibull".NULLifevent = "pwexp"- t_itv
a vector indicating interval lengths where the exponential rates provided in
lambdaCapply. Note that the length oft_itvis at least 1 less than that oflambdaCand that the final value rate inlambdaCapplies after timesum(t_itv).NULLifevent = "weibull"- change
A list of additional derivered covariates to be used in simulating time-to-events. See details
- keep
A character vector specifying which of the original covariates (i.e. those not derived via the
changeargument) should be included into the model to simulate time-to-events. If left unspecified all covariates will be included.
Value
a .eventClass class containing time-to-events information
a matrix containing simulated time-to-events information
Details
The change argument is used to specify additional derived covariates to be used when
simulating time-to-events. For example, let’s say have 3 covariates cov1, cov2 & cov3
but that we also wish to include a new covariate that is an interaction
between cov1 and cov2 as well as another covariate that is equal to the sum of
cov2 and cov3; we could implement this as follows:
set_event(
event = "weibull",
shape = 0.9,
lambdaC = 0.0135,
beta = c(5, 3, 1, 7, 9),
change = list(
c("cov1", "*", "cov2"),
c("cov2", "+", "cov3")
)
)Note that in the above example 5 values have been specified to beta,
3 for the original three covariates
and 2 for the two additional derived covariates included via change.
Variables derived via change are automatically included in the model regardless
of whether they are listed in keep or not. Likewise, these covariates are derived
separately and not via a standard R formula, that is to say including an interaction
term does not automatically include the individual fixed effects.
Examples
# time-to-event follows a Weibull distribution
set_event(event = "weibull", shape = 0.9, lambdaC = 0.0135)
#> An object of class ".eventClass"
#> Slot "event":
#> [1] "weibull"
#>
#> Slot "lambdaC":
#> [1] 0.0135
#>
#> Slot "shape":
#> [1] 0.9
#>
#> Slot "t_itv":
#> NULL
#>
#> Slot "beta":
#> NULL
#>
#> Slot "change":
#> NULL
#>
#> Slot "keep":
#> NULL
#>
# time-to-event follows a piece-wise exponential distribution
set_event(event = "pwexp", t_itv = 1, lambdaC = c(0.1, 0.02))
#> An object of class ".eventClass"
#> Slot "event":
#> [1] "pwexp"
#>
#> Slot "lambdaC":
#> [1] 0.10 0.02
#>
#> Slot "shape":
#> NULL
#>
#> Slot "t_itv":
#> [1] 1
#>
#> Slot "beta":
#> NULL
#>
#> Slot "change":
#> NULL
#>
#> Slot "keep":
#> NULL
#>