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 datasim_cont() function. Must contain columns named 'treatment', 'response' and 'period'.

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 (1/σθ21/\sigma^2_{\theta}) of the prior regarding the treatment effect θ\theta. I.e. θN(0,σθ2)\theta \sim N(0, \sigma^2_{\theta}). Default=0.001.

prec_eta

Double. Precision (1/ση021/\sigma^2_{\eta_0}) of the prior regarding the control mean η0\eta_0. I.e. η0N(0,ση02)\eta_0 \sim N(0, \sigma^2_{\eta_0}). Default=0.001.

tau_a

Double. Parameter aτa_{\tau} of the Gamma distribution for the precision parameter τ\tau in the model for the time trend. I.e., τGamma(aτ,bτ)\tau \sim Gamma(a_{\tau},b_{\tau}). Default=0.1.

tau_b

Double. Parameter bτb_{\tau} of the Gamma distribution for the precision parameter τ\tau in the model for the time trend. I.e., τGamma(aτ,bτ)\tau \sim Gamma(a_{\tau},b_{\tau}). Default=0.01.

prec_a

Double. Parameter aσ2a_{\sigma^2} of the Gamma distribution regarding the precision of the responses. I.e., 1/σ2Gamma(aσ2,bσ2)1/\sigma^2 \sim Gamma(a_{\sigma^2},b_{\sigma^2}). Default=0.001.

prec_b

Double. Parameter bσ2b_{\sigma^2} of the Gamma distribution regarding the precision of the responses. I.e., 1/σ2Gamma(aσ2,bσ2)1/\sigma^2 \sim Gamma(a_{\sigma^2},b_{\sigma^2}). Default=0.001.

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 CC 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=1c=1 and the time interval corresponding to the beginning of the trial by c=Cc=C. The analysis is performed as soon as the analyzed treatment arm finishes in the trial.

The model is defined as follows:

E(yj)=η0+θkj+αcjE(y_j) = \eta_0 + \theta_{k_j} + \alpha_{c_j}

where yjy_j is the continuous response for patient jj. The model intercept η0\eta_0 denotes the response of the control group at time of the analysis, θkj\theta_{k_j} is the effect of the treatment arm kk that patient jj was enrolled in, relative to control. For the parameters η0\eta_0 and θkj\theta_{k_j}, normal prior distributions are assumed, with mean 0 and variances ση02\sigma^2_{\eta_0} and σθ2\sigma^2_{\theta}, respectively:

η0N(0,ση02)\eta_0 \sim \mathcal{N}(0, \sigma^2_{\eta_0})

θkjN(0,σθ2)\theta_{k_j} \sim \mathcal{N}(0, \sigma^2_{\theta})

In the Time Machine, time effect is represented by αcj\alpha_{c_j}, which is the change in the response in time bucket cjc_j (which denotes the time bucket in which patient jj is enrolled) compared to the most recent time bucket c=1c=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:

α1=0\alpha_1 = 0

α2N(0,1/τ)\alpha_2 \sim \mathcal{N}(0, 1/\tau)

αcN(2αc1αc2,1/τ),3cC\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:

τGamma(aτ,bτ)\tau \sim Gamma(a_{\tau}, b_{\tau})

The precision of the individual patient responses (1/σ21/\sigma^2) is also assumed to have a Gamma hyperprior distribution:

1/σ2Gamma(aσ2,bσ2)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:

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)



[Package NCC version 1.0 Index]