Originally, the data was collected in a Microsoft Excel spreadsheet in wide format. In accordance with the study protocol, the following data was entered anonymized for each participant after completion of the 6th wear period:
Id (factor; 1…40),
sex (factor; male = 0, female = 1),
age (continuous; years),
study_arm (factor; Group 1 (unaware) = 0, Group 2 (aware) = 1),
and data exported from the Theramon program:
for each wear period the duration of the specific period (days) (delta_visit.days) and
the wear time (WT) in hours (wear_time.visit).
This data was used to calculate other variables for each patient:
change in mean wear time between visits (h) (delta_visit.hours) for each study subject
and mean wear time (h) (mean_wear_h) for each study subject.
Do aid further analysis, the row number corresponding to an individual observation was added to the theramon_long data frame (“Observation number”).
For analysis, this table was reshaped to “long” format in Excel and then imported in SPSS 29. Each variable was labelled accordingly and if necessary, factor levels were defined. The statistical analysis and figure preparation was done using this data file (Theramon_data_long.sav).
The final statistical analysis was done using R (R Core Team 2025) using RStudio version 2025.5.1.513. All analysis and output was documented in this Quarto file.
In R, the variable cum_days representing cumulative treatment time (days) was additionally calculated using the R base function cumsum.
Data is available in the data frame theramon_long, which is in “long” format. Variable definitions are summarized in Table 1.1.
3.1 Time interval (days) between two consecutive appointments
Variables:
delta_visit.days: duration of the individual wear periods T0-T1; 2: T1-T2; …; T5-T6;
mean_diff_days: covers duration of all individual wear periods (T0-T1 up to and including T5-T6, i.e. T0-T6) and is the mean of these for each individual case.
Patients were scheduled for six clinical appointments following a biweekly protocol. However, due to factors such as professional obligations, illness, and other circumstances, strict adherence to the prescribed schedule was not always feasible. In Table 3.1 the intervals between two consecutive appointments (i.e., wear periods) and the overall mean time of all wear periods covering periods T0-T1, …, T5-T6 were summarized.
Table 3.1: Number of days between appointments and overall time between appointments
Characteristic
Overall N = 401
Group 1 N = 201
Group 2 N = 201
Period T0-T1
Mean (SD) Median (Q1, Q3)
14.6 (2.7) 14.0 (14.0, 14.0)
13.9 (1.9) 14.0 (13.0, 14.0)
15.2 (3.3) 14.0 (14.0, 15.0)
Period T1-T2
Mean (SD) Median (Q1, Q3)
14.5 (2.2) 14.0 (14.0, 15.0)
14.0 (2.3) 14.0 (14.0, 14.0)
15.0 (2.0) 14.0 (14.0, 15.0)
Period T2-T3
Mean (SD) Median (Q1, Q3)
15.3 (4.0) 14.0 (14.0, 14.5)
15.1 (4.2) 14.0 (14.0, 14.0)
15.4 (3.9) 14.0 (13.5, 15.5)
Period T3-T4
Mean (SD) Median (Q1, Q3)
14.1 (1.2) 14.0 (14.0, 14.0)
13.9 (0.9) 14.0 (14.0, 14.0)
14.2 (1.5) 14.0 (14.0, 14.0)
Period T4-T5
Mean (SD) Median (Q1, Q3)
14.6 (2.3) 14.0 (14.0, 14.0)
14.7 (2.8) 14.0 (14.0, 15.0)
14.6 (1.6) 14.0 (14.0, 14.0)
Period T5-T6
Mean (SD) Median (Q1, Q3)
16.0 (6.2) 14.5 (14.0, 16.0)
17.1 (7.9) 15.0 (14.0, 16.0)
15.0 (3.9) 14.0 (14.0, 15.0)
Period T0-T6
14.8 (1.5) 14.3 (14.0, 15.4)
14.8 (1.8) 14.3 (13.9, 15.0)
14.9 (1.1) 14.5 (14.0, 15.5)
1Mean (SD) Median (Q1, Q3)
The abacus plot (Figure 3.1) shows the distribution of visits among the patients, illustrating both the clustering of appointment waves and the individuals’ variability in time intervals between consecutive appointments.
Figure 3.1: Abacus plot: visit waves for each study subject. Grey shaded areas label the 14-days visit intervals as proposed.
3.2 Wear period specific wear time
Variables:
wear_time.visit: wear time for each case/wear period
mean_wear_h: mean wear time over all wear periods for each case
Wear times per wear period and the overall mean wear time (periods T0-T1 … T5-T6) were summarized for both study arms and the complete study group in Table 3.2.
Table 3.2: Descriptive statistics of wear_time.visit by study_arm and visit and mean_wear_h by study_arm.
Characteristic
Overall N = 401
Group 1 N = 201
Group 2 N = 201
Period T0-T1
15.7 (3.9) 15.8 (13.8, 19.2)
14.3 (4.3) 14.7 (12.8, 17.0)
17.1 (3.1) 17.4 (14.9, 19.6)
Period T1-T2
15.9 (4.2) 16.3 (13.3, 19.3)
14.5 (4.6) 15.8 (12.0, 17.1)
17.3 (3.4) 17.7 (15.4, 20.1)
Period T2-T3
15.5 (4.6) 15.7 (13.0, 19.2)
14.2 (5.0) 14.7 (11.8, 17.5)
16.9 (3.9) 17.2 (15.3, 19.9)
Period T3-T4
15.2 (4.5) 15.9 (13.2, 19.1)
13.7 (4.9) 14.2 (10.8, 17.0)
16.7 (3.5) 16.9 (15.4, 19.5)
Period T4-T5
14.9 (4.5) 15.5 (12.0, 18.3)
13.1 (4.9) 12.6 (10.3, 16.6)
16.7 (3.2) 17.4 (14.4, 19.4)
Period T5-T6
14.0 (4.5) 13.7 (11.5, 18.4)
12.3 (4.6) 12.5 (9.1, 14.9)
15.7 (3.9) 16.0 (12.2, 19.4)
Period T0-T6
15.2 (4.1) 15.2 (12.6, 18.8)
13.7 (4.4) 14.8 (11.7, 16.1)
16.7 (3.2) 16.7 (14.6, 19.7)
1Mean (SD) Median (Q1, Q3)
Trajectories of each participant overlaid with the mean WT (and its 95% CI) at each visit for both study arms are shown in Figure 3.2.
Show the code
set.seed(2)options(ggplot2.discrete.colour ="npg")fig.study_indiv <- theramon_long |>select(Id, study_arm, visit, wear_time.visit) |>mutate(visit =as.numeric(visit)) |>arrange(Id, visit) |>ggplot(aes(x = visit, y = wear_time.visit, group = Id)) +geom_line(colour ="lightgrey") +geom_point(colour ="darkgrey") +guides(shape ="none", color ="none") +labs(x ="Wear period", y ="Mean wear time (h) with 95% CI") +scale_x_continuous(limit =c(.5, 6.5), breaks =seq(1, 6, by =1), expand =c(0,0), labels =c("T0-T1", "T1-T2", "T2-T3", "T3-T4", "T4-T5", "T5-T6")) +scale_y_continuous(limit =c(0, 25), breaks =seq(0, 25, by =10), expand =c(0,0)) +facet_grid(cols =vars(study_arm), labeller =labeller(study_arm =c("0"="Temperature", "1"="Wear time"))) +theme_bw(base_size =14) +theme(axis.title.x =element_text(size =14, face ="bold"),axis.text.x =element_text(size =12),axis.title.y =element_text(size =14, face ="bold"),axis.text.y =element_text(size =12))+theme(legend.position ="bottom") +theme(panel.grid.major.y =element_line(color ="darkgrey", linetype ="dashed"), panel.grid.minor.y =element_blank(), panel.grid.major.x =element_blank()) +theme(strip.text.x =element_text(size =12, face ="bold"))fig.study_indiv2 <- fig.study_indiv +stat_summary(fun.data ="mean_cl_normal", geom ="errorbar", width =0.2, color ="red", group =1, linewidth = .8) +stat_summary(fun ="mean", geom ="point", shape =16, size =2.5, color ="red", group =1)fig.study_indiv2
Figure 3.2: Individual mean WT for the six wear periods and both study arms
The individual patters during the six periods of this study are shown in the next figure (Figure 3.3). Ordinary least square regression was applied to visualize the individual differences as indicated by the different, individual slopes.
Figure 3.3: Wear time (WT) for each individual case across the six follow-up appointments. Slopes were calculated for each case separately.
To get an idea on the different patters, the slopes calcuated for Figure 3.3 above, were used to classify the study subjects into those with increasing slope over the six periods (slope >= 0.1), with constant slope over the six periods (-0.1 <= slope <= 0.1), and with decreasing slope (slope < -0.1). The findings were summarized in Figure 3.4.
Subject-specific trajectories (Figure 3.3 and Figure 3.4) revealed extensive variation in wear_time.visit between subjects. Within each subject wear_time.visit was also fluctuating over time, and either slightly increasing, nearly constant, or decreasing (Figure 3.4).
Due to the nested structure of the data, a linear mixed model (LMM) was established to test the effect of time (variable visit; ordered), study arm* (variable study_arm; nominal; Group 1 (unaware) = 0, Group 2 (aware) = 1), and the fixed predictors (sex, age) on wear period specific wear time (h) (variable wear_time.visit), and potential interactions between them after controlling for subject (Id) variation.
4.1 Model selection
Models of different complexity were evaluated in this order:
fit_lmer_1ml: Intercept model: first and second level predictors (visit and study_arm) and the random intercept (Id).
fit_lmer_2aml: Potential interaction between visit and study_arm.
fit_lmer_3aml: Addition of sex, and age.
fit_lmer_4ml: Potential interaction between study_arm and sex.
fit_lmer_4bml: Potential interaction between study_arm and age.
The first model (fit_lmer_1ml) consisted of wear_time.visit as response variable, visit (time; first level) and study_arm (groups; second level), and the subject-contributed random effects (Id). The latter were described by:
the random intercept, which is an estimate for the variation of the intercept and as such wear time at visit (wear_time.visit) between subjects (Id).
the level 1-residues, describing the variation of wear_time.visit within a study subject.
Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's method [lmerModLmerTest]
Formula: wear_time.visit ~ visit + study_arm + (1 | Id)
Data: theramon_long
AIC BIC logLik -2*log(L) df.resid
1080 1112 -531 1062 231
Scaled residuals:
Min 1Q Median 3Q Max
-4.148 -0.399 0.027 0.467 2.888
Random effects:
Groups Name Variance Std.Dev.
Id (Intercept) 13.66 3.70
Residual 2.77 1.66
Number of obs: 240, groups: Id, 40
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 14.161 0.874 46.741 16.21 < 2e-16 ***
visitT1-T2 0.191 0.372 200.000 0.51 0.609
visitT2-T3 -0.158 0.372 200.000 -0.42 0.672
visitT3-T4 -0.458 0.372 200.000 -1.23 0.220
visitT4-T5 -0.784 0.372 200.000 -2.11 0.036 *
visitT5-T6 -1.652 0.372 200.000 -4.44 1.5e-05 ***
study_armGroup 2 (aware) 3.042 1.188 40.000 2.56 0.014 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Correlation of Fixed Effects:
(Intr) vT1-T2 vT2-T3 vT3-T4 vT4-T5 vT5-T6
visitT1-T2 -0.213
visitT2-T3 -0.213 0.500
visitT3-T4 -0.213 0.500 0.500
visitT4-T5 -0.213 0.500 0.500 0.500
visitT5-T6 -0.213 0.500 0.500 0.500 0.500
stdy_rmG2() -0.680 0.000 0.000 0.000 0.000 0.000
4.1.2 Interaction between visit and study_arm
Next, a potential interaction between time and study arm (visit:study_arm) was analyzed and compared this model to the previous one without interaction, i.e., fit_lmer_1ml.
To test, if the addition of study_arm:visit interaction was contributing further information to the fit_lmer_1ml model a likelihood ratio test was applied:
According to this results, the interaction between visit and study_arm was not significant. Therefore, this interaction was not further considered and we continued with the less complex model fit_lmer_1ml.
4.1.3 Addition of the level-invariant predictors sex and age
Next, we added the level-invariant predictors sex and ageto the model from the previous step, yielding model
fit_lmer_3aml: wear_time.visit ~ visit + study_arm + sex + age + (1|Id).
To avoid, that the reference of age is set to 0 years, the minimum age of this patient cohort (i.e., 17.2 years) was subtracted from age to yield age-min(age) as reference.
The model’s summary is shown next:
Show the code
set.seed(2)options(width =100)options(digits =3)fit_lmer_3aml <- lmerTest::lmer(wear_time.visit ~ visit + study_arm + sex +I(age-17.2) + (1| Id), data = theramon_long, REML =FALSE)summary(fit_lmer_3aml)
Table 4.3: Performance of the accepted model final.
AIC
AICc
BIC
R2_cond
R2_marg
ICC
RMSE
Sigma
1,070
1,071
1,108
0.861
0.263
0.812
1.524
1.685
4.2.2 LMM model assumptions
The final model was then analyzed for deviations from the assumptions of linear mixed models using performance::check_model() from the “performance” R package (Figure 4.1).
Figure 4.1: Accepted model overview. Visual check of various model assumptions using performance::check_model().
4.2.2.1 Heteroscedasticity
Checking the assumption of heteroscedasticity using the Breusch-Pagan test was applied as implemented in the check_heteroscedasticity() function implemented in the “performance” R package (Lüdecke et al. 2021) and depicted (Figure 4.2)
OK: Error variance appears to be homoscedastic (p = 0.209).
4.2.2.2 Outliers
Check for potential outliers using check_outliers() from the “performance” R package using Cook’s distance.
Show the code
performance::check_outliers(final)
1 outlier detected: case 145.
- Based on the following method and threshold: cook (0.5).
- For variable: (Whole model).
Observation “145” (Id = 3, visit = T3-T4) was identified as a potential outlier according to Cook’s distance. The related data is summarized in the following table (Table 4.4).
Table 4.4: Observations identified as potential outliers by observation #145.
Row
Id
Study arm
Sex
Period
WT at visit (h)
145
3
Group 2 (aware)
Female
T3-T4
8.6
A sensitivity analysis was done (see to section Section 4.2.4 for details).
4.2.2.3 multicollinearity of model terms
Multicollinearity of the model terms was assessed with check_collinerarity() from the “performance” R package (Lüdecke et al. 2021) by calculating the (generalized) variance inflation factor (VIF) (Table 4.5).
For all predictors, the VIF was <5. This indicated a low correlation of that predictor with the other predictors.
4.2.2.4 Normality
The model check for (non-)normality of residuals was done using a Q-Q and density plots (check_normality from R package “performance”) (Figure 4.3). This command checks the studentized residuals of a mixed model for normal distribution.
Visual inspection of this plot showed a deviation from normal distribution especially in the lower (i.e., left) tail of the distribution.
Show the code
set.seed(2)options(ggplot2.discrete.colour ="npg") plot(performance::check_normality(final), type ="qq")plot(performance::check_normality(final), type ="density")
(a) Q-Q plot
(b) Density plot
Figure 4.3: Check normality of residuals.
4.2.2.5 Uniformity of ranodmized quantile residuals
To test the model for uniformity of randomized quantile residuals, the command check_residuals() (R package “performance”) was applied to the final model. This function “checks generalized linear (mixed) models for uniformity of randomized quantile residuals, which can be used to identify typical model misspecification problems, such as over/underdispersion, zero-inflation, and residual spatial and temporal autocorrelation. … [This is done by simulated quantile residuals.] … The command then ”tests the distribution of the quantile residuals against the uniform distribution using a Kolmogorov-Smirnov test.” (from the help page of this function)
We fitted a linear mixed model (estimated using REML and nloptwrap optimizer) to predict
wear_time.visit with visit, study_arm and sex (formula: wear_time.visit ~ visit + study_arm + sex +
study_arm:sex). The model included Id as random effect (formula: ~1 | Id). The model's total
explanatory power is substantial (conditional R2 = 0.86) and the part related to the fixed effects
alone (marginal R2) is of 0.26. The model's intercept, corresponding to visit = T0-T1, study_arm =
Group 1 (unaware) and sex = Male, is at 10.16 (95% CI [6.90, 13.43], t(37.69) = 6.30, p < .001).
Within this model:
- The effect of visit [T1-T2] is statistically non-significant and positive (beta = 0.19, 95% CI
[-0.55, 0.93], t(195.00) = 0.51, p = 0.613; Std. beta = 0.04, 95% CI [-0.13, 0.21])
- The effect of visit [T2-T3] is statistically non-significant and negative (beta = -0.16, 95% CI
[-0.90, 0.59], t(195.00) = -0.42, p = 0.676; Std. beta = -0.04, 95% CI [-0.21, 0.13])
- The effect of visit [T3-T4] is statistically non-significant and negative (beta = -0.46, 95% CI
[-1.20, 0.29], t(195.00) = -1.22, p = 0.226; Std. beta = -0.10, 95% CI [-0.27, 0.07])
- The effect of visit [T4-T5] is statistically significant and negative (beta = -0.78, 95% CI
[-1.53, -0.04], t(195.00) = -2.08, p = 0.039; Std. beta = -0.18, 95% CI [-0.35, -9.46e-03])
- The effect of visit [T5-T6] is statistically significant and negative (beta = -1.65, 95% CI
[-2.40, -0.91], t(195.00) = -4.38, p < .001; Std. beta = -0.38, 95% CI [-0.55, -0.21])
- The effect of study arm [Group 2 (aware)] is statistically significant and positive (beta = 7.17,
95% CI [2.94, 11.41], t(36.00) = 3.43, p = 0.002; Std. beta = 1.64, 95% CI [0.67, 2.60])
- The effect of sex [Female] is statistically significant and positive (beta = 5.33, 95% CI [1.59,
9.06], t(36.00) = 2.89, p = 0.006; Std. beta = 1.22, 95% CI [0.36, 2.07])
- The effect of study arm [Group 2 (aware)] × sex [Female] is statistically significant and
negative (beta = -5.54, 95% CI [-10.58, -0.49], t(36.00) = -2.23, p = 0.032; Std. beta = -1.26, 95%
CI [-2.42, -0.11])
Standardized parameters were obtained by fitting the model on a standardized version of the
dataset. 95% Confidence Intervals (CIs) and p-values were computed using a Wald t-distribution with
Kenward-Roger approximation.
4.2.3.2 Model figures
Figure 4.4 depicts the plots from the final model showing the random estimates and marginal effects next to each other.
Figure 4.4: Plots from the final model (Kenward-Roger). (a) Forest plot of random effects by subject’s Id. (b) Plot of the predicted values (marginal effects) for wear_time.visit by visit, study_arm and sex.
set.seed(2)options(ggplot2.discrete.colour ="npg") theramon_long.lmer <- theramon_long |>mutate(final.fixef =predict(final, re.form =NA), # exclude all random effects (cf. lme4::predict.merMod)final.ranef =predict(final, re.form =~(1|Id))) # include all random effectsfig.wear_time.Id_lmm <- theramon_long.lmer |>ggplot(aes(x = visit, y = wear_time.visit, group =1)) +geom_point(shape =21, size =2, fill ="white") +# geom_smooth(method = "lm", se = FALSE, aes(alpha = "OLS"), colour = "black", linewidth = 0.5) +geom_line(aes(y = final.fixef, alpha ="fixed effects only"), colour ="blue", linewidth =0.7, linetype =1) +geom_line(aes(y = final.ranef, alpha ="fixed and random effects"), colour ="green", linewidth =0.7, linetype =1) +guides(shape ="none") +labs(x ="Wear period", y ="Wear time (h)") +scale_y_continuous(limit =c(0, 30), breaks =seq(0, 30, by =10), expand =c(0,0)) +scale_alpha_manual(name =NULL, values =c(1,1), breaks =c("fixed effects only", "fixed and random effects")) +facet_wrap(facet =vars(Id), ncol =5, labeller = case_names) +theme_bw(base_size =14) +theme(legend.position ="bottom") +theme(panel.grid.major.y =element_line(colour ="lightgrey", linetype ="dashed"),panel.grid.minor.y =element_blank(), panel.grid.major.x =element_blank()) +theme(strip.text.x =element_text(size =11, color ="black", face ="bold")) +theme(axis.text.x =element_text(angle =30, vjust =0.8, hjust =0.8))fig.wear_time.Id_lmm
Figure 4.5: Mean WT for each individual case across the six follow-up appointments: prediction using fixed effects only and including random effects.
4.2.3.3 Multiple comparisions
Using functions from the “emmeans” package (Lenth 2025), marginal means (aka Least-Squares Means) and contrasts were calculated for specified factors or factor combinations from the final model. The p-values are based on the t-distribution using degres of freedom based on Kenward-Roger’s method. Adjustments for multiple comparisons were not applied, instead unadjusted p-values were reported.
Table 4.7: Observations identified as potential outliers or influental observations.
Observation number
Id
Study arm
Sex
Period
WT at visit (h)
145
3
Group 2 (aware)
Female
T3-T4
8.64
1
2
Group 1 (unaware)
Male
T0-T1
4.95
4
2
Group 1 (unaware)
Male
T1-T2
3.30
7
2
Group 1 (unaware)
Male
T2-T3
3.32
10
2
Group 1 (unaware)
Male
T3-T4
1.88
13
2
Group 1 (unaware)
Male
T4-T5
1.52
16
2
Group 1 (unaware)
Male
T5-T6
2.07
Additionally, subject/case #2 displayed very low wear times at each visit, ranging from 1.52 hours to 4.95 hours (Table 4.7). See also Figure 4.6 below. This case might also be influencing the model.
In this section, we evaluated possible effects of these observations on the linear mixed model in three steps:
outlier observation removed from the data set
influential case #2 removed from the data set
outlier observation and potential influential case #2 removed from the data set
Each time, the model was run on the reduced dataset and the model parameter were then compared.
Figure 4.6: Potentially influenting case #2 and outlier observation from case #3.
4.2.4.1 Outlier
To evaluate, if potential outliers (Table 4.7) had an impact on model performance, the final model was updated by removing observation #145 (Id = 3, Group 2, female, Visit 3 = T3-T4) yielding model final.rowdel.
Additionally, the wear times of case #2 were very short in comparison to the other study participants (Table 4.7). What happens, if these were removed from the model? The final model was updated by deleting the observations related to case #2 from the model yielding model final.case2:
OK: No outliers detected.
- Based on the following method and threshold: cook (0.5).
- For variable: (Whole model)
4.2.4.4 Comparison
In Table 4.8 we compared the accepted model (final) with those after elemination of the potential outlier (final.rowdel), removal of the potentially influencing case 2 (final.case2), or both (final.reduced).
final.rowdel: The intercept increased, the estimates for visit(T1-T2) up to visit(T5-T6) increased, the same for sex(Female). The estimates for study_arm = Group 2 and for the interaction term study_arm(Group2):sex(Female) decreased.
final.case2: Slight changes in the estimates, sex(Female) and the interaction term study_arm(Group2):sex(Female) were not significant anymore and should be probably removed from the analysis?!
final.reduced: The number of observations was reduced from 240 to 233, and the number of groups dropped from 40 to 39. In comparison to the final model (complete data frame) deleting the outlier and the influential subject led to a better performance of the final.reduced model as indicated by the lower AIC and BIC. After adjusting for the other variables in the model, the estimates for each visit period slightly increased, and the estimate for study_arm was reduced. After adjusting for the other variables in the model, the estimate for female sex was reduced by 1.71, and was not significant anymore. After adjusting for the other variables in the model, the estimate for the interaction of study_arm:sex for female subjects increased by -1.82, and also was not significant anymore.
Table 4.8: Comparision between the accpeted (final) and those after elimination of outlier and/or potentially influenting case #2.
final
final.rowdel
final.case2
final.reduced
Predictors
Estimates
p
Estimates
p
Estimates
p
Estimates
p
(Intercept)
10.16 (6.90 – 13.43)
<0.001
10.13 (6.87 – 13.39)
<0.001
11.84 (8.37 – 15.30)
<0.001
11.80 (8.35 – 15.25)
<0.001
T0-T1
Reference
Reference
Reference
Reference
T1-T2
0.19 (-0.55 – 0.93)
0.613
0.19 (-0.51 – 0.90)
0.594
0.24 (-0.52 – 1.00)
0.537
0.24 (-0.48 – 0.96)
0.515
T2-T3
-0.16 (-0.90 – 0.59)
0.676
-0.16 (-0.86 – 0.55)
0.659
-0.12 (-0.88 – 0.64)
0.756
-0.12 (-0.84 – 0.60)
0.742
T3-T4
-0.46 (-1.20 – 0.29)
0.226
-0.25 (-0.96 – 0.46)
0.494
-0.39 (-1.15 – 0.37)
0.311
-0.17 (-0.90 – 0.55)
0.637
study_armGroup 2 (aware):sexFemale
-5.54 (-10.58 – -0.49)
0.032
-5.43 (-10.47 – -0.39)
0.035
-3.83 (-8.85 – 1.20)
0.131
-3.72 (-8.73 – 1.30)
0.141
T4-T5
-0.78 (-1.53 – -0.04)
0.039
-0.78 (-1.49 – -0.08)
0.029
-0.72 (-1.48 – 0.04)
0.064
-0.72 (-1.44 – 0.00)
0.051
T5-T6
-1.65 (-2.40 – -0.91)
<0.001
-1.65 (-2.36 – -0.95)
<0.001
-1.62 (-2.38 – -0.86)
<0.001
-1.62 (-2.34 – -0.90)
<0.001
Group 1 (unaware)
Reference
Reference
Reference
Reference
Group 2 (aware)
7.17 (2.94 – 11.41)
0.002
7.17 (2.94 – 11.40)
0.001
5.46 (1.16 – 9.76)
0.014
5.46 (1.17 – 9.75)
0.014
Male
Reference
Reference
Reference
Reference
Female
5.33 (1.59 – 9.06)
0.006
5.33 (1.60 – 9.06)
0.006
3.62 (-0.24 – 7.48)
0.065
3.62 (-0.24 – 7.47)
0.065
Random Effects
σ2
2.84
2.56
2.89
2.59
τ00
12.25 Id
12.26 Id
10.93 Id
10.94 Id
ICC
0.81
0.83
0.79
0.81
N
40 Id
40 Id
39 Id
39 Id
Observations
240
239
234
233
Marginal R2 / Conditional R2
0.263 / 0.861
0.271 / 0.874
0.177 / 0.828
0.185 / 0.844
4.2.5 Dealing with non-normality
Various transformations of the response variable wear_time.visit were tested, including log(), log10(), and sqrt() transformations (not shown). Additionally, cubed (wear_time.visit^3) and Box-Cox transformations were tested.
All tests were done with the model for the reduced data set (i.e., after removal of the outlier and the influential case; final.reduced) and its data set theramon_long.reduced.
Finally, Box-Cox transformation was tested as implemented in powerTransform() of the “car” R package yielding \lambda = 2.7, \gamma = 22 (Fox and Weisberg 2019a). A Box-Cox transformation was applied to wear_time.visit in the theramon_long.reduced data frame accordingly.
Show the code
set.seed(2)options(width =100)pwr.theramon <- car::powerTransform(final.reduced, family ="bcnPower")cat("*** powerTransform*** \n")
*** powerTransform***
Show the code
summary(pwr.theramon)
bcn - Box-Cox Power transformation to Normality
allowing for negative values, lmer fit
Estimated power, lambda
Est.Power Std.Err. Wald Lower Bound Wald Upper Bound
[1,] 2.67 0.842 1.02 4.32
Estimated location, gamma
Est.gamma Std.Err. Wald Lower Bound Wald Upper Bound
[1,] 22.5 14 0 49.8
Likelihood ratio tests about transformation parameters
LRT df pval
LR test, lambda = (0) 43.2 1 4.96e-11
LR test, lambda = (1) 16.9 1 3.90e-05
Figure 4.7: Normality plots of the models after (a) cubed, and (b) Box-Cox transformation
Show the code
plot(theramon.reduced_eff, axes =list(y=list(type="response"), x =list(rug =FALSE)),ylim =c(8, 20),lines =list(multiline=TRUE, lwd =2),confit=list(style ="bands"),lattice=list(key.args=list(x=0.9, y =0.2, corner =c(1,1), padding.text=1.25)),xlab ="Visit", ylab ="Wear time (h)", main ="")plot(theramon.reduced_cubed_eff, axes =list(y=list(type="response"), x =list(rug =FALSE)),ylim =c(8, 20), lines =list(multiline=TRUE, lwd =2),confit=list(style ="bands"),lattice=list(key.args=list(x=0.9, y =0.2, corner =c(1,1), padding.text=1.25)),xlab ="Visit", ylab ="Wear time (h)", main ="")plot(theramon.reduced_pwr_eff, axes =list(y=list(type="response"), x =list(rug =FALSE)),ylim =c(8, 20), lines =list(multiline=TRUE, lwd =2),confit=list(style ="bands"),lattice=list(key.args=list(x=0.9, y =0.2, corner =c(1,1), padding.text=1.25)),xlab ="Visit", ylab ="Wear time (h)", main ="")
(a) Not transformed
(b) Cubed transformation
(c) Box-Cox transformation
Figure 4.8: Effect plot for the interaction of sex and study_arm in the mixed-effect models fit to the reduced data set. Effect of transformations applied to response variable wear_time.visit.
We fitted a linear mixed model (estimated using REML and nloptwrap optimizer) to predict wear_time.visit with
visit, study_arm and sex (formula: wear_time.visit ~ visit + study_arm + sex + study_arm:sex). The model
included Id as random effect (formula: ~1 | Id). The model's total explanatory power is substantial
(conditional R2 = 0.84) and the part related to the fixed effects alone (marginal R2) is of 0.19. The model's
intercept, corresponding to visit = T0-T1, study_arm = Group 1 (unaware) and sex = Male, is at 11.80 (95% CI
[8.35, 15.25], t(36.36) = 6.93, p < .001). Within this model:
- The effect of visit [T1-T2] is statistically non-significant and positive (beta = 0.24, 95% CI [-0.48,
0.96], t(189.00) = 0.65, p = 0.515; Std. beta = 0.06, 95% CI [-0.12, 0.24])
- The effect of visit [T2-T3] is statistically non-significant and negative (beta = -0.12, 95% CI [-0.84,
0.60], t(189.00) = -0.33, p = 0.742; Std. beta = -0.03, 95% CI [-0.21, 0.15])
- The effect of visit [T3-T4] is statistically non-significant and negative (beta = -0.17, 95% CI [-0.90,
0.55], t(189.04) = -0.47, p = 0.637; Std. beta = -0.04, 95% CI [-0.23, 0.14])
- The effect of visit [T4-T5] is statistically non-significant and negative (beta = -0.72, 95% CI [-1.44,
2.76e-03], t(189.00) = -1.97, p = 0.051; Std. beta = -0.18, 95% CI [-0.37, 7.01e-04])
- The effect of visit [T5-T6] is statistically significant and negative (beta = -1.62, 95% CI [-2.34, -0.90],
t(189.00) = -4.44, p < .001; Std. beta = -0.41, 95% CI [-0.59, -0.23])
- The effect of study arm [Group 2 (aware)] is statistically significant and positive (beta = 5.46, 95% CI
[1.17, 9.75], t(34.99) = 2.58, p = 0.014; Std. beta = 1.39, 95% CI [0.30, 2.48])
- The effect of sex [Female] is statistically non-significant and positive (beta = 3.62, 95% CI [-0.24,
7.47], t(34.99) = 1.91, p = 0.065; Std. beta = 0.92, 95% CI [-0.06, 1.90])
- The effect of study arm [Group 2 (aware)] × sex [Female] is statistically non-significant and negative
(beta = -3.72, 95% CI [-8.73, 1.30], t(34.99) = -1.50, p = 0.141; Std. beta = -0.94, 95% CI [-2.22, 0.33])
Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95%
Confidence Intervals (CIs) and p-values were computed using a Wald t-distribution with Kenward-Roger
approximation.
Table 4.9 compares final and final.reduced models.
Figure 4.9: Plots from the final.reduced model. (a) Forest plot of random effects by subject’s Id. (b) Plot of the predicted values (marginal effects) for wear_time.visit by visit, study_arm and sex.
4.3.1 Multiple comparisons
Multiple comparisons of the final.reduced model factors was done as described above (see Section 4.2.3.3). The p-values are based on the t-distribution using degrees of freedom based on Kenward-Roger’s method. Adjustments for multiple comparisons were not applied, instead unadjusted p-values were reported.
set.seed(2)options(ggplot2.discrete.colour ="npg") theramon_long.reduced_lmer <- theramon_long.reduced |>mutate(final_reduced.fixef =predict(final.reduced, re.form =NA), # exclude all random effects (cf. lme4::predict.merMod)final_reduced.ranef =predict(final.reduced, re.form =~(1|Id))) # include all random effectstheramon_long.joined_lmer <-left_join(theramon_long.lmer, theramon_long.reduced_lmer, by =c("Id", "study_arm", "visit", "wear_time.visit")) |>select(Id, study_arm, age.x, sex.x, visit, visit_n.x, wear_time.visit, row.x, cum_days.x, final.fixef, final.ranef, final_reduced.fixef, final_reduced.ranef) |>rename(age = age.x,sex = sex.x,visit_n = visit_n.x,row = row.x,cum_days = cum_days.x)fig.wear_time.joined_Id_lmm <- theramon_long.joined_lmer |>ggplot(aes(x = visit, y = wear_time.visit, group =1)) +geom_point(shape =21, size =2, fill ="white") +# geom_smooth(method = "lm", se = FALSE, aes(alpha = "OLS"), colour = "black", linewidth = 0.5) +geom_line(aes(y = final_reduced.fixef, alpha ="fixed effects only"), colour ="blue", linewidth =0.7, linetype =1) +geom_line(aes(y = final_reduced.ranef, alpha ="fixed and random effects"), colour ="green", linewidth =0.7, linetype =1) +guides(shape ="none") +labs(x ="Wear period", y ="Wear time (h)") +scale_y_continuous(limit =c(0, 30), breaks =seq(0, 30, by =10), expand =c(0,0)) +scale_alpha_manual(name =NULL, values =c(1,1), breaks =c("fixed effects only", "fixed and random effects")) +facet_wrap(facet =vars(Id), ncol =5, labeller = case_names) +theme_bw(base_size =14) +theme(legend.position ="bottom") +theme(panel.grid.major.y =element_line(colour ="lightgrey", linetype ="dashed"),panel.grid.minor.y =element_blank(), panel.grid.major.x =element_blank()) +theme(strip.text.x =element_text(size =11, color ="black", face ="bold")) +theme(axis.text.x =element_text(angle =30, vjust =0.8, hjust =0.8))fig.wear_time.joined_Id_lmm
Figure 4.10: Wear time of each individual case across the six follow-up appointments using the ‘reduced’ model: prediction using fixed effects only and including random effects.
Allaire, JJ, Yihui Xie, Christophe Dervieux, Jonathan McPherson, Javier Luraschi, Kevin Ushey, Aron Atkins, et al. 2024. rmarkdown: Dynamic Documents for r. https://github.com/rstudio/rmarkdown.
Bates, Douglas, Martin Mächler, Ben Bolker, and Steve Walker. 2015. “Fitting Linear Mixed-Effects Models Using lme4.”Journal of Statistical Software 67 (1): 1–48. https://doi.org/10.18637/jss.v067.i01.
Fox, John. 2003. “Effect Displays in R for Generalised Linear Models.”Journal of Statistical Software 8 (15): 1–27. https://doi.org/10.18637/jss.v008.i15.
Fox, John, and Jangman Hong. 2009. “Effect Displays in R for Multinomial and Proportional-Odds Logit Models: Extensions to the effects Package.”Journal of Statistical Software 32 (1): 1–24. https://doi.org/10.18637/jss.v032.i01.
Fox, John, and Sanford Weisberg. 2018. “Visualizing Fit and Lack of Fit in Complex Regression Models with Predictor Effect Plots and Partial Residuals.”Journal of Statistical Software 87 (9): 1–27. https://doi.org/10.18637/jss.v087.i09.
Kuznetsova, Alexandra, Per B. Brockhoff, and Rune H. B. Christensen. 2017. “lmerTest Package: Tests in Linear Mixed Effects Models.”Journal of Statistical Software 82 (13): 1–26. https://doi.org/10.18637/jss.v082.i13.
Leifeld, Philip. 2013. “texreg: Conversion of Statistical Model Output in R to LaTeX and HTML Tables.”Journal of Statistical Software 55 (8): 1–24. https://doi.org/10.18637/jss.v055.i08.
Lüdecke, Daniel, Mattan S. Ben-Shachar, Indrajeet Patil, Philip Waggoner, and Dominique Makowski. 2021. “performance: An R Package for Assessment, Comparison and Testing of Statistical Models.”Journal of Open Source Software 6 (60): 3139. https://doi.org/10.21105/joss.03139.
Lüdecke, Daniel, Mattan S. Ben-Shachar, Indrajeet Patil, Brenton M. Wiernik, Etienne Bacher, Rémi Thériault, and Dominique Makowski. 2022. “easystats: Framework for Easy Statistical Modeling, Visualization, and Reporting.”CRAN. https://doi.org/10.32614/CRAN.package.easystats.
Makowski, Dominique, Daniel Lüdecke, Indrajeet Patil, Rémi Thériault, Mattan S. Ben-Shachar, and Brenton M. Wiernik. 2023. “Automated Results Reporting as a Practical Tool to Improve Reproducibility and Methodological Best Practices Adoption.”CRAN. https://easystats.github.io/report/.
R Core Team. 2025. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.
Sjoberg, Daniel D., Karissa Whiting, Michael Curry, Jessica A. Lavery, and Joseph Larmarange. 2021. “Reproducible Summary Tables with the Gtsummary Package.”The R Journal 13: 570–80. https://doi.org/10.32614/RJ-2021-053.
Wickham, Hadley, Mara Averick, Jennifer Bryan, Winston Chang, Lucy D’Agostino McGowan, Romain François, Garrett Grolemund, et al. 2019. “Welcome to the tidyverse.”Journal of Open Source Software 4 (43): 1686. https://doi.org/10.21105/joss.01686.
Xie, Yihui. 2014. “knitr: A Comprehensive Tool for Reproducible Research in R.” In Implementing Reproducible Computational Research, edited by Victoria Stodden, Friedrich Leisch, and Roger D. Peng. Chapman; Hall/CRC.
———. 2015. Dynamic Documents with R and Knitr. 2nd ed. Boca Raton, Florida: Chapman; Hall/CRC. https://yihui.org/knitr/.
———. 2025. knitr: A General-Purpose Package for Dynamic Report Generation in R. https://yihui.org/knitr/.
Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown.