Model-based analysis for continuous data using discontinuous piecewise polynomials per calendar time unit
Source:R/piecewise_cal_cont.R
piecewise_cal_cont.Rd
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 meanslower_ci
- lower limit of the (1-2*alpha
)*100% confidence intervalupper_ci
- upper limit of the (1-2*alpha
)*100% confidence intervalreject_h0
- indicator of whether the null hypothesis was rejected or not (p_val
<alpha
)model
- fitted model
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.02687242
#>
#> $treat_effect
#> [1] 0.2742664
#>
#> $lower_ci
#> [1] -0.004438983
#>
#> $upper_ci
#> [1] 0.5529717
#>
#> $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)
#> 5.439e-01
#> as.factor(treatment)1
#> 2.387e-01
#> as.factor(treatment)2
#> 1.161e-01
#> as.factor(treatment)3
#> 2.743e-01
#> poly(j, degree = poly_degree, raw = TRUE)1
#> -3.500e-01
#> poly(j, degree = poly_degree, raw = TRUE)2
#> 2.658e-02
#> poly(j, degree = poly_degree, raw = TRUE)3
#> -5.337e-04
#> as.factor(cal_time)2
#> 5.677e+01
#> as.factor(cal_time)3
#> -7.760e+01
#> as.factor(cal_time)4
#> -3.728e+02
#> as.factor(cal_time)5
#> -7.226e+02
#> as.factor(cal_time)6
#> -3.693e+03
#> as.factor(cal_time)7
#> 5.616e+02
#> as.factor(cal_time)8
#> -1.705e+03
#> as.factor(cal_time)9
#> -3.309e+03
#> as.factor(cal_time)10
#> -1.019e+04
#> as.factor(cal_time)11
#> -1.693e+03
#> as.factor(cal_time)12
#> 1.435e+03
#> as.factor(cal_time)13
#> 6.408e+03
#> as.factor(cal_time)14
#> -2.390e+03
#> as.factor(cal_time)15
#> -2.312e+04
#> as.factor(cal_time)16
#> -7.590e+04
#> as.factor(cal_time)17
#> 1.013e+05
#> as.factor(cal_time)18
#> 6.591e+04
#> as.factor(cal_time)19
#> 1.128e+05
#> as.factor(cal_time)20
#> -7.578e+04
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)2
#> -4.380e+00
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)2
#> 1.001e-01
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)2
#> -5.698e-04
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)3
#> 3.855e+00
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)3
#> -7.824e-02
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)3
#> 7.796e-04
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)4
#> 1.340e+01
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)4
#> -1.784e-01
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)4
#> 1.120e-03
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)5
#> 1.963e+01
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)5
#> -1.980e-01
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)5
#> 1.041e-03
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)6
#> 8.191e+01
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)6
#> -6.263e-01
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)6
#> 2.002e-03
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)7
#> -1.057e+01
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)7
#> 4.402e-02
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)7
#> 3.820e-04
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)8
#> 2.661e+01
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)8
#> -1.612e-01
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)8
#> 7.631e-04
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)9
#> 4.723e+01
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)9
#> -2.477e-01
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)9
#> 8.811e-04
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)10
#> 1.287e+02
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)10
#> -5.657e-01
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)10
#> 1.288e-03
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)11
#> 1.909e+01
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)11
#> -9.562e-02
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)11
#> 6.183e-04
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)12
#> -1.525e+01
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)12
#> 2.981e-02
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)12
#> 4.659e-04
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)13
#> -6.291e+01
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)13
#> 1.813e-01
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)13
#> 3.063e-04
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)14
#> 2.171e+01
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)14
#> -9.028e-02
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)14
#> 5.971e-04
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)15
#> 1.926e+02
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)15
#> -5.593e-01
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)15
#> 1.026e-03
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)16
#> 5.879e+02
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)16
#> -1.542e+00
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)16
#> 1.837e-03
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)17
#> -7.352e+02
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)17
#> 1.754e+00
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)17
#> -9.029e-04
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)18
#> -4.531e+02
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)18
#> 1.013e+00
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)18
#> -2.609e-04
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)19
#> -7.296e+02
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)19
#> 1.547e+00
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)19
#> -5.973e-04
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(cal_time)20
#> 4.693e+02
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(cal_time)20
#> -9.937e-01
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(cal_time)20
#> 1.198e-03
#>
#>