You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -94,10 +95,11 @@ We can visualize the power curve for different sample sizes using the following
94
95
plot(N_ss)
95
96
```
96
97
97
-
Consider now we want to adjust the sample size for an anticipated drop-out rate of 20% in each group. We can modify the code as follows:
98
+
To account for an anticipated dropout rate of 20% in each group, we need to adjust the sample size. The following code demonstrates how to incorporate this adjustment using a custom optimization routine. This routine is designed to find the smallest integer sample size that meets or exceeds the target power. It employs a stepwise search strategy, starting with larger step sizes and progressively refining them as it approaches the solution.
98
99
99
100
```{r}
100
-
(N_ss <- sampleSize(
101
+
# Adjusted sample size calculation with 20% dropout rate
102
+
(N_ss_dropout <- sampleSize(
101
103
power = 0.90, # Target power
102
104
alpha = 0.025, # Type-I error rate
103
105
mu_list = list("R" = mu_r, "T" = mu_t), # Means for reference and treatment groups
@@ -109,13 +111,13 @@ Consider now we want to adjust the sample size for an anticipated drop-out rate
optimization_method = "fast", # Fast optimization method
114
115
ncores = 1, # Single-core processing
115
116
nsim = 1000, # Number of simulations
116
117
seed = 1234 # Random seed for reproducibility
117
118
))
118
119
```
119
-
120
+
121
+
Previously, finding the required sample size took `r nrow(N_ss$table.iter)` iterations. With the fast optimizer, the number of iterations is reduced to `r nrow(N_ss_dropout$table.iter)`, significantly improving efficiency.
0 commit comments