Mixed regression model analysis for continuous data using the covariates treatment and calendar time unit as fixed effects and the interaction between them as a random effect
Source:R/mixmodel_int_cal_cont.R
mixmodel_int_cal_cont.Rd
This function performs linear mixed model regression taking into account all trial data until the arm under study leaves the trial and adjusting for calendar time units as random factors.
Usage
mixmodel_int_cal_cont(
data,
arm,
alpha = 0.025,
ci = FALSE,
unit_size = 25,
ncc = TRUE,
check = TRUE,
...
)
Arguments
- data
Data frame with trial data, e.g. result from the
datasim_cont()
function. Must contain columns named 'treatment' and 'response'.- 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.
- ci
Logical. Indicates whether confidence intervals should be computed. Default=FALSE.
- 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.
- 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
# \donttest{
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")
mixmodel_int_cal_cont(data = trial_data, arm = 3, ci = TRUE)
#> boundary (singular) fit: see help('isSingular')
#> Computing profile confidence intervals ...
#> Computing profile confidence intervals ...
#> $p_val
#> [1] 0.01628808
#>
#> $treat_effect
#> [1] 0.2860109
#>
#> $lower_ci
#> [1] 0.03009963
#>
#> $upper_ci
#> [1] 0.5419223
#>
#> $reject_h0
#> [1] TRUE
#>
#> $model
#> Linear mixed model fit by REML ['lmerModLmerTest']
#> Formula: response ~ as.factor(treatment) + as.factor(cal_time) + (1 |
#> treatment_aux:cal_time)
#> Data: data_new
#> REML criterion at convergence: 1404.058
#> Random effects:
#> Groups Name Std.Dev.
#> treatment_aux:cal_time (Intercept) 0.0000
#> Residual 0.9759
#> Number of obs: 499, groups: treatment_aux:cal_time, 42
#> Fixed Effects:
#> (Intercept) as.factor(treatment)1 as.factor(treatment)2
#> 0.09716 0.29135 0.23416
#> as.factor(treatment)3 as.factor(cal_time)2 as.factor(cal_time)3
#> 0.28601 -0.16013 -0.21577
#> as.factor(cal_time)4 as.factor(cal_time)5 as.factor(cal_time)6
#> 0.11338 -0.16546 0.27937
#> as.factor(cal_time)7 as.factor(cal_time)8 as.factor(cal_time)9
#> -0.27597 0.06038 -0.34488
#> as.factor(cal_time)10 as.factor(cal_time)11 as.factor(cal_time)12
#> -0.71329 -0.08104 -0.13804
#> as.factor(cal_time)13 as.factor(cal_time)14 as.factor(cal_time)15
#> 0.59036 0.51443 0.21746
#> as.factor(cal_time)16 as.factor(cal_time)17 as.factor(cal_time)18
#> 0.04312 0.06533 -0.06903
#> as.factor(cal_time)19 as.factor(cal_time)20
#> 0.02600 0.22503
#> optimizer (nloptwrap) convergence code: 0 (OK) ; 0 optimizer warnings; 1 lme4 warnings
#>
# }