Spline regression analysis for continuous data with knots placed according to calendar time units
Source:R/splines_cal_cont.R
splines_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 regression splines with knots placed according to calendar time units.
Usage
splines_cal_cont(
data,
arm,
alpha = 0.025,
unit_size = 25,
ncc = TRUE,
bs_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.
- bs_degree
Integer. Degree of the polynomial spline. Default=3 for cubic spline.
- 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
)knots
- positions of the knots in terms of patient indexmodel
- 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")
splines_cal_cont(data = trial_data, arm = 3)
#> $p_val
#> [1] 0.009252795
#>
#> $treat_effect
#> [1] 0.3322323
#>
#> $lower_ci
#> [1] 0.05601945
#>
#> $upper_ci
#> [1] 0.6084451
#>
#> $reject_h0
#> [1] TRUE
#>
#> $knots
#> [1] 25 50 75 100 125 150 175 200 225 250 275 300 325 350 375 400 425 450 475
#>
#> $model
#>
#> Call:
#> lm(formula = response ~ as.factor(treatment) + bs(j, knots = bs_knots,
#> degree = bs_degree), data = data_new)
#>
#> Coefficients:
#> (Intercept)
#> -0.09124
#> as.factor(treatment)1
#> 0.03769
#> as.factor(treatment)2
#> 0.28531
#> as.factor(treatment)3
#> 0.33223
#> bs(j, knots = bs_knots, degree = bs_degree)1
#> 0.26792
#> bs(j, knots = bs_knots, degree = bs_degree)2
#> 0.45899
#> bs(j, knots = bs_knots, degree = bs_degree)3
#> 0.18926
#> bs(j, knots = bs_knots, degree = bs_degree)4
#> 0.09361
#> bs(j, knots = bs_knots, degree = bs_degree)5
#> 0.69449
#> bs(j, knots = bs_knots, degree = bs_degree)6
#> -0.26855
#> bs(j, knots = bs_knots, degree = bs_degree)7
#> 0.17355
#> bs(j, knots = bs_knots, degree = bs_degree)8
#> 0.50860
#> bs(j, knots = bs_knots, degree = bs_degree)9
#> 0.62676
#> bs(j, knots = bs_knots, degree = bs_degree)10
#> -0.23094
#> bs(j, knots = bs_knots, degree = bs_degree)11
#> -0.29864
#> bs(j, knots = bs_knots, degree = bs_degree)12
#> 0.34810
#> bs(j, knots = bs_knots, degree = bs_degree)13
#> 0.41220
#> bs(j, knots = bs_knots, degree = bs_degree)14
#> -0.33012
#> bs(j, knots = bs_knots, degree = bs_degree)15
#> 0.39030
#> bs(j, knots = bs_knots, degree = bs_degree)16
#> 0.18737
#> bs(j, knots = bs_knots, degree = bs_degree)17
#> 0.24988
#> bs(j, knots = bs_knots, degree = bs_degree)18
#> -0.36218
#> bs(j, knots = bs_knots, degree = bs_degree)19
#> 0.65213
#> bs(j, knots = bs_knots, degree = bs_degree)20
#> -0.82740
#> bs(j, knots = bs_knots, degree = bs_degree)21
#> 0.61778
#> bs(j, knots = bs_knots, degree = bs_degree)22
#> 0.32423
#>
#>