-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path01-SampleSize-ContinuousOutcome.qmd
127 lines (94 loc) · 5.13 KB
/
01-SampleSize-ContinuousOutcome.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Two-arm study with a continuous primary outcome
This vignette was motivated by a consulting of CTU Bern (C2956). It describes the sample size approach for a randomized Bayesian phase II trial with a continuous outcome that is corrected for the baseline value.
## Study description
### Primary objective
The study examines the impact of a treatment on upper limb motor activity in everyday life.
### Primary outcome
The primary endpoint is bimanual hand function measured with the Assisting Hand Assessment (AHA) after treatment.
### Study design
In this exploratory randomized Bayesian phase-II trial, we evaluate the probability that the investigational treatment is superior to the standard of care using Bayesian statistics. If this probability exceeds 90%, we deem the treatment as promising.
## Methods and assumptions
We calculate the Bayesian probability of success (equivalent to the frequentist power) for the primary outcome using Monte-Carlo simulations. Success is defined as a difference in AHA greater than 0 in favor of the treatment. We simulate outcome and its respective baseline data from a multivariate normal distribution with a correlation of 0.5 and evaluate the treatment difference using Bayesian linear regression. We calculate the probability of success twice, first, using a non-informative prior (i.e. not integrating any prior information) and second, using an informative prior with an effect size of 1.0 and a precision of 1.0, which was based on a previous publication. This prior corresponds to approximately two patients in terms of weight.
- Allocation ratio: 1:1
- Effect measure: Difference in AHA (corrected for the baseline value)
- Analysis approach: Bayesian linear regression using INLA
- Expected effect size: 0.6
- Expected correlation between baseline and outcome value: 0.5
- Probability threshold to claim success: 0.9
- Non-informative prior: Mean 0, precision 0.001
- Informative prior: Mean 1.0, precision 1.0
- Total sample size: 34
- Number of simulations: 10,000
## Calculation using R
### R-code
```{r}
#| echo: true
#| warning: false
#| eval: false
#install.packages("C:/download/INLA_24.02.09.zip", repos = NULL, type = "bin") # manual download of latest version
library(INLA)
library(MASS)
rm(list = ls())
set.seed(123)
# Set parameters
n_simulations <- 10
n_patients <- 17 # per arm
effect_size <- 0.6
correlation <- 0.5
sd <- 1.0
cor_matrix <- matrix(c(sd, correlation, correlation, sd), nrow = 2)
# Define prior and threshold probability
sd_p <- 1
prec_p <- 1/sd_p^2
mean_p <- 1.0
prior_custom <- list(mean=list(treatment=mean_p), prec=list(treatment=prec_p))
threshold_prob <- 0.9
success_noprior <- numeric(n_simulations)
success_prior <- numeric(n_simulations)
# Simulate and fit the model multiple times
for (i in 1:n_simulations) {
print(i)
# Generate simulated data
control_data <- mvrnorm(n = n_patients, mu = c(0, 0), Sigma = cor_matrix)
control_data <- data.frame(
baseline = control_data[, 1],
outcome = control_data[, 2],
treatment = 0
)
treatment_data <- mvrnorm(n = n_patients, mu = c(0, effect_size), Sigma = cor_matrix)
treatment_data <- data.frame(
baseline = treatment_data[, 1],
outcome = treatment_data[, 2],
treatment = 1
)
data <- rbind(control_data, treatment_data)
# Model formula
formula <- outcome ~ treatment + baseline # Model formula
# Bayesian INLA model without prior (non-informative)
model_noprior <- inla(formula, data = data, family = "gaussian")
model_noprior$summary.fixed
1 - inla.pmarginal(0, model_noprior$marginals.fixed$treatment)
# Model with informative prior
model_prior <- inla(formula, data = data, family = "gaussian", control.fixed=prior_custom)
model_prior$summary.fixed
1 - inla.pmarginal(0, model_prior$marginals.fixed$treatment)
# Posterior of treatment coefficient
posterior_prob_noprior <- 1 - inla.pmarginal(0, model_noprior$marginals.fixed$treatment)
success_noprior[i] <- posterior_prob_noprior > threshold_prob
posterior_prob_prior <- 1 - inla.pmarginal(0, model_prior$marginals.fixed$treatment)
success_prior[i] <- posterior_prob_prior > threshold_prob
}
# Calculate probability of success
prob_success_noprior <- mean(success_noprior)
prob_success_power_prior <- mean(success_prior)
```
### Result of simulation
The probability of success based on the non-informative and informative prior is 0.77 and 0.84, respectively.
## Analysis approach
The primary outcome will be assessed in both groups before and after the training.
The difference in AHA between groups will be evaluated using a Bayesian linear regression model, adjusting for baseline values and stratification factors employed during randomization. An informative Gaussian prior, as described in the sample size section above, will be incorporated into the model. From the posterior distribution, we will calculate the mean difference along with a 95% credible interval as well as the probability that investigational treatment is superior to standard of care. In a sensitivity analysis, a non-informative prior will be employed.
### Author {-}
Andreas Limacher, PhD\
Department of Clinical Research\
University of Bern\
3012 Bern, Switzerland