Skip to contents

This function performs linear regression taking into account all trial data until the arm under study leaves the trial and adjusting for time using discontinuous piecewise polynomials in each calendar time unit.

Usage

piecewise_cal_cont(
  data,
  arm,
  alpha = 0.025,
  unit_size = 25,
  ncc = TRUE,
  poly_degree = 3,
  check = TRUE,
  ...
)

Arguments

data

Data frame with trial data, e.g. result from the datasim_cont() function. Must contain columns named 'treatment', 'response' and 'j'.

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. Significance level (one-sided). Default=0.025.

unit_size

Integer. Number of patients per calendar time unit. Default=25.

ncc

Logical. Indicates whether to include non-concurrent data into the analysis. Default=TRUE.

poly_degree

Integer. Degree of the piecewise polynomial. Default=3.

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.

Value

List containing the following elements regarding the results of comparing arm to control:

  • p-val - p-value (one-sided)

  • treat_effect - estimated treatment effect in terms of the difference in means

  • lower_ci - lower limit of the (1-2*alpha)*100% confidence interval

  • upper_ci - upper limit of the (1-2*alpha)*100% confidence interval

  • reject_h0 - indicator of whether the null hypothesis was rejected or not (p_val < alpha)

  • model - fitted model

Author

Pavla Krotka

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")

piecewise_cal_cont(data = trial_data, arm = 3)
#> $p_val
#> [1] 0.0442195
#> 
#> $treat_effect
#> [1] 0.2391153
#> 
#> $lower_ci
#> [1] -0.03612439
#> 
#> $upper_ci
#> [1] 0.5143549
#> 
#> $reject_h0
#> [1] FALSE
#> 
#> $model
#> 
#> Call:
#> lm(formula = response ~ as.factor(treatment) + poly(j, degree = poly_degree, 
#>     raw = TRUE) * as.factor(cal_time), data = data_new)
#> 
#> Coefficients:
#>                                                      (Intercept)  
#>                                                        2.525e-02  
#>                                            as.factor(treatment)1  
#>                                                        2.253e-01  
#>                                            as.factor(treatment)2  
#>                                                        3.356e-01  
#>                                            as.factor(treatment)3  
#>                                                        2.391e-01  
#>                       poly(j, degree = poly_degree, raw = TRUE)1  
#>                                                       -2.229e-01  
#>                       poly(j, degree = poly_degree, raw = TRUE)2  
#>                                                        2.919e-02  
#>                       poly(j, degree = poly_degree, raw = TRUE)3  
#>                                                       -9.052e-04  
#>                                             as.factor(cal_time)2  
#>                                                       -7.137e+01  
#>                                             as.factor(cal_time)3  
#>                                                        3.535e+02  
#>                                             as.factor(cal_time)4  
#>                                                       -3.104e+02  
#>                                             as.factor(cal_time)5  
#>                                                        7.416e+02  
#>                                             as.factor(cal_time)6  
#>                                                       -1.630e+03  
#>                                             as.factor(cal_time)7  
#>                                                        2.628e+03  
#>                                             as.factor(cal_time)8  
#>                                                       -1.647e+02  
#>                                             as.factor(cal_time)9  
#>                                                        3.493e+03  
#>                                            as.factor(cal_time)10  
#>                                                       -2.023e+04  
#>                                            as.factor(cal_time)11  
#>                                                       -2.003e+03  
#>                                            as.factor(cal_time)12  
#>                                                       -3.882e+03  
#>                                            as.factor(cal_time)13  
#>                                                        1.089e+04  
#>                                            as.factor(cal_time)14  
#>                                                       -1.504e+04  
#>                                            as.factor(cal_time)15  
#>                                                       -2.946e+04  
#>                                            as.factor(cal_time)16  
#>                                                        3.175e+04  
#>                                            as.factor(cal_time)17  
#>                                                        2.972e+04  
#>                                            as.factor(cal_time)18  
#>                                                        4.811e+04  
#>                                            as.factor(cal_time)19  
#>                                                       -7.754e+04  
#>                                            as.factor(cal_time)20  
#>                                                        1.527e+05  
#>  poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)2  
#>                                                        6.047e+00  
#>  poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)2  
#>                                                       -1.825e-01  
#>  poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)2  
#>                                                        2.213e-03  
#>  poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)3  
#>                                                       -1.656e+01  
#>  poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)3  
#>                                                        2.346e-01  
#>  poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)3  
#>                                                       -4.669e-04  
#>  poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)4  
#>                                                        1.050e+01  
#>  poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)4  
#>                                                       -1.422e-01  
#>  poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)4  
#>                                                        1.318e-03  
#>  poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)5  
#>                                                       -1.986e+01  
#>  poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)5  
#>                                                        1.515e-01  
#>  poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)5  
#>                                                        3.645e-04  
#>  poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)6  
#>                                                        3.543e+01  
#>  poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)6  
#>                                                       -2.821e-01  
#>  poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)6  
#>                                                        1.509e-03  
#>  poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)7  
#>                                                       -4.964e+01  
#>  poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)7  
#>                                                        2.854e-01  
#>  poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)7  
#>                                                        2.453e-04  
#>  poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)8  
#>                                                        3.034e+00  
#>  poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)8  
#>                                                       -4.528e-02  
#>  poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)8  
#>                                                        9.360e-04  
#>  poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)9  
#>                                                       -4.617e+01  
#>  poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)9  
#>                                                        1.753e-01  
#>  poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)9  
#>                                                        6.064e-04  
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)10  
#>                                                        2.557e+02  
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)10  
#>                                                       -1.104e+00  
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)10  
#>                                                        2.412e-03  
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)11  
#>                                                        2.087e+01  
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)11  
#>                                                       -9.923e-02  
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)11  
#>                                                        9.831e-04  
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)12  
#>                                                        4.142e+01  
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)12  
#>                                                       -1.748e-01  
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)12  
#>                                                        1.077e-03  
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)13  
#>                                                       -1.030e+02  
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)13  
#>                                                        2.970e-01  
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)13  
#>                                                        5.618e-04  
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)14  
#>                                                        1.348e+02  
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)14  
#>                                                       -4.306e-01  
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)14  
#>                                                        1.304e-03  
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)15  
#>                                                        2.420e+02  
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)15  
#>                                                       -6.906e-01  
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)15  
#>                                                        1.508e-03  
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)16  
#>                                                       -2.481e+02  
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)16  
#>                                                        6.180e-01  
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)16  
#>                                                        3.431e-04  
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)17  
#>                                                       -2.135e+02  
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)17  
#>                                                        4.829e-01  
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)17  
#>                                                        4.962e-04  
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)18  
#>                                                       -3.284e+02  
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)18  
#>                                                        7.190e-01  
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)18  
#>                                                        3.375e-04  
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)19  
#>                                                        5.007e+02  
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)19  
#>                                                       -1.106e+00  
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)19  
#>                                                        1.677e-03  
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)20  
#>                                                       -9.392e+02  
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)20  
#>                                                        1.897e+00  
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)20  
#>                                                       -4.111e-04  
#> 
#>