Here is the design of a clinical trial:

Official Title: Optimizing Message Framing for Healthy Habits for Patients With Type 2 Diabetes - Phase II (Pragmatic Trial)

Included conditions:
- Diabetes Mellitus, Type 2
- Medication Adherence

Study Armgroups:
- {'label': 'Reinforcement Learning Intervention Arm', 'type': 'EXPERIMENTAL', 'description': 'Up to daily, tailored text messages.', 'interventionNames': ['Behavioral: Reinforcement Learning']}
- {'label': 'Control Arm', 'type': 'NO_INTERVENTION', 'description': 'Up to daily, untailored text messages.'}

Interventions:
- {'type': 'BEHAVIORAL', 'name': 'Reinforcement Learning', 'description': "Participants in the intervention arm will receive up to daily, tailored text messages based on their electronic pill bottle-measured adherence. Given the participants' baseline characteristics and time-varying responses to the messages, a reinforcement learning algorithm will deliver different text messages and adapt over time to determine which type of messaging works best for each individual participant.", 'armGroupLabels': ['Reinforcement Learning Intervention Arm']}

Primary Outcomes:
- {'measure': 'Medication Adherence', 'description': 'Medication adherence to type 2 diabetes oral medications (averaged) as measured by the number of dates and times of pillbottle openings in the electronic pill bottles', 'timeFrame': '6 months'}

Please estimate the sample size based on the assumption: 
The study assumes a standard deviation (SD) of 12.5% for adherence, SD of 1.3 for HbA1c, a power of 0.8, and a significance level (α) of 0.05. It also considers up to 25% missingness for the glycaemic control outcome and uses multiple imputation if >10% of participants have missing HbA1c data.
Analytic plan and sample size
        We will report means and frequencies of prerandomisation variables separately by intervention and control arm, comparing these values using absolute standardised differences. The outcomes will be evaluated using intention-to-treat principles among all randomised participants.
        In the primary analysis, we will evaluate adherence and glycaemic control using generalised estimating equations with an identity link function and normally distributed errors. We will also adjust for the block randomised design. We do not expect any missing data for the primary outcome, but may have up to 25% missingness for the glycaemic control outcome.46 54 If >10% of participants have missing HbA1c data, we will repeat our analyses using multiple imputation.54 55 A similar approach will be taken for self-reported adherence, except using a log link function and Poisson distributed errors to generate relative risks of the proportion of adherent patients in the intervention versus control arms.56 In secondary analyses, we will control for any differences in baseline variables between the arms despite randomisation.
        As a sensitivity analysis, we will censor patients in the analysis when they have stopped using the electronic pill bottle for >30âdays. We will also evaluate the change in HbA1c from baseline until the end of follow-up and differences in self-reported adherence separately for the three items that make up the self-reported scale we are using. For glycaemic control (HbA1c) and self-reported adherence, we will also conduct complete case analyses. Similarly, subgroup analyses will include stratification by age, sex, race/ethnicity, baseline HbA1c, baseline self-reported adherence and number of study medications.
        Our study should be sufficiently powered to detect clinically meaningful differences in the primary outcome. With 60 subjects, we estimated that we would have the power to detect a 10% difference in average adherence over the 6-month follow-up period between the two arms, assuming an SD=12.5%, power=0.8 and Î±=0.05. With this sample size, we would also be able to detect an HbA1c difference of 1.0% between arms (assuming SD=1.3) and 50% relative difference in self-reported adherence.54
        On trial completion, we will cluster intervention patients by their response to different text message factors and evaluate the ability to predict these cluster phenotypes using baseline information before randomization. Based on prior work and the general 1:10 rule of thumb for predictor parameters, we expect to elucidate at least two unique patient characteristics for the clusters.25 57 We have further classified each text message as quantitative (ie, containing numbers), social reinforcement with specific reference to their doctor, or containing lifestyle information, which we will also incorporate as post-hoc prediction factors to evaluate responsiveness to individual texts; in total, there will be at least 5000 individual text messages sent. This exploratory prediction modelling on trial completion could provide a more accurate âstarting pointâ on which future programmes could begin to adapt to further personalise message content.