Model-based analysis for continuous data using discontinuous piecewise polynomials per period
Source:R/piecewise_cont.R
piecewise_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 period.
Arguments
- data
Data frame with trial data, e.g. result from the
datasim_cont()
function. Must contain columns named 'treatment', 'response', 'period' 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.
- 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_cont(data = trial_data, arm = 3)
#> $p_val
#> [1] 0.0005842033
#>
#> $treat_effect
#> [1] 0.4382052
#>
#> $lower_ci
#> [1] 0.1745748
#>
#> $upper_ci
#> [1] 0.7018357
#>
#> $reject_h0
#> [1] TRUE
#>
#> $model
#>
#> Call:
#> lm(formula = response ~ as.factor(treatment) + poly(j, degree = poly_degree,
#> raw = TRUE) * as.factor(period), data = data_new)
#>
#> Coefficients:
#> (Intercept)
#> 4.257e-01
#> as.factor(treatment)1
#> 4.938e-01
#> as.factor(treatment)2
#> 5.293e-01
#> as.factor(treatment)3
#> 4.382e-01
#> poly(j, degree = poly_degree, raw = TRUE)1
#> -5.673e-02
#> poly(j, degree = poly_degree, raw = TRUE)2
#> 1.444e-03
#> poly(j, degree = poly_degree, raw = TRUE)3
#> -9.536e-06
#> as.factor(period)2
#> -2.705e+00
#> as.factor(period)3
#> 2.285e+01
#> as.factor(period)4
#> 6.011e+02
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(period)2
#> 1.000e-01
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(period)2
#> -1.727e-03
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(period)2
#> 1.014e-05
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(period)3
#> -1.663e-01
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(period)3
#> -7.462e-04
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(period)3
#> 8.825e-06
#> poly(j, degree = poly_degree, raw = TRUE)1:as.factor(period)4
#> -3.978e+00
#> poly(j, degree = poly_degree, raw = TRUE)2:as.factor(period)4
#> 7.554e-03
#> poly(j, degree = poly_degree, raw = TRUE)3:as.factor(period)4
#> 2.866e-06
#>
#>