timemachine_cont {NCC} | R Documentation |
Time machine analysis for continuous data
Description
This function performs analysis of continuous data using the Time Machine approach. It takes into account all data until the investigated arm leaves the trial. It is based on linear regression with treatment as a categorical variable and covariate adjustment for time via a second-order Bayesian normal dynamic linear model (separating the trial into buckets of pre-defined size).
Usage
timemachine_cont(
data,
arm,
alpha = 0.025,
prec_theta = 0.001,
prec_eta = 0.001,
tau_a = 0.1,
tau_b = 0.01,
prec_a = 0.001,
prec_b = 0.001,
bucket_size = 25,
check = TRUE,
...
)
Arguments
data |
Data frame with trial data, e.g. result from the |
arm |
Integer. Index of the treatment arm under study to perform inference on (vector of length 1). This arm is compared to the control group. |
alpha |
Double. Decision boundary (one-sided). Default=0.025. |
prec_theta |
Double. Precision ( |
prec_eta |
Double. Precision ( |
tau_a |
Double. Parameter |
tau_b |
Double. Parameter |
prec_a |
Double. Parameter |
prec_b |
Double. Parameter |
bucket_size |
Integer. Number of patients per time bucket. Default=25. |
check |
Logical. Indicates whether the input parameters should be checked by the function. Default=TRUE, unless the function is called by a simulation function, where the default is FALSE. |
... |
Further arguments passed by wrapper functions when running simulations. |
Details
The Time Machine divides the trial duration into C
calendar time intervals of equal length ("buckets"), which are indexed backwards in time. That is to say, the most recent time interval is denoted by c=1
and the time interval corresponding to the beginning of the trial by c=C
.
The analysis is performed as soon as the analyzed treatment arm finishes in the trial.
The model is defined as follows:
E(y_j) = \eta_0 + \theta_{k_j} + \alpha_{c_j}
where y_j
is the continuous response for patient j
.
The model intercept \eta_0
denotes the response of the control group at time of the analysis, \theta_{k_j}
is the effect of the treatment arm k
that patient j
was enrolled in, relative to control.
For the parameters \eta_0
and \theta_{k_j}
, normal prior distributions are assumed, with mean 0 and variances \sigma^2_{\eta_0}
and \sigma^2_{\theta}
, respectively:
\eta_0 \sim \mathcal{N}(0, \sigma^2_{\eta_0})
\theta_{k_j} \sim \mathcal{N}(0, \sigma^2_{\theta})
In the Time Machine, time effect is represented by \alpha_{c_j}
, which is the change in the response in time bucket c_j
(which denotes the time bucket in which patient j
is enrolled) compared to the most recent time bucket c=1
and is modeled using a Bayesian second-order normal dynamic linear model.
This creates a smoothing over the control response, such that closer time buckets are modeled with more similar response rates:
\alpha_1 = 0
\alpha_2 \sim \mathcal{N}(0, 1/\tau)
\alpha_c \sim \mathcal{N}(2 \alpha_{c-1} - \alpha_{c-2}, 1/\tau), 3 \le c \le C
where \tau
denotes the drift parameter that controls the degree of smoothing over the time buckets and is assumed to have a Gamma hyperprior distribution:
\tau \sim Gamma(a_{\tau}, b_{\tau})
The precision of the individual patient responses (1/\sigma^2
) is also assumed to have a Gamma hyperprior distribution:
1/\sigma^2 \sim Gamma(a_{\sigma^2}, b_{\sigma^2})
Value
List containing the following elements regarding the results of comparing arm
to control:
-
p-val
- posterior probability that the difference in means is less than zero -
treat_effect
- posterior mean of difference in means -
lower_ci
- lower limit of the (1-2*alpha
)*100% credible interval for difference in means -
upper_ci
- upper limit of the (1-2*alpha
)*100% credible interval for difference in means -
reject_h0
- indicator of whether the null hypothesis was rejected or not (p_val
<alpha
)
Author(s)
Dominic Magirr, Peter Jacko
Examples
trial_data <- datasim_cont(num_arms = 3, n_arm = 100, d = c(0, 100, 250),
theta = rep(0.25, 3), lambda = rep(0.15, 4), sigma = 1, trend = "linear")
timemachine_cont(data = trial_data, arm = 3)