How to combine sites with some limitation?

14 Views Asked by At

I have a dataset from a real clinical trial. This is the virtual sample:

SiteID  Control Placebo Rate
1   30  8   3.8
3   9   4   2.3
4   27  9   3
5   23  3   7.7
6   3   1   3
7   23  7   3.3
8   13  6   2.2
9   19  1   19
10  5       
11  23  15  1.5
12  32  8   4
13  5   3   1.7
14  23  7   3.3
18  18  4   4.5
20  1   4   0.3

The first column is the ID of site where we decided to carry out tril, the second column is number of samples in the control group and the third is number of samples in the placebo group and the 4th colmun is column2/column3, round to 0.1. Here is what I am going to do:

The rate of control group vs placebo group in my study is designed as 3:1. Some Site have unbalance rate or too small number of samples should be combined as a new site.

For example: Site1 and site3 could be combined as site21, with 39 samples in control group and 12 samples in placebo group and 39/12=3.25 as its rate, whic is more closer to 3(compared with 3.8 and 2.3). Site4 just have its rate as 3 and proper number of samples, so it should be reserved as its raw condition.

So here comes my question:
Could you please help me to combine these sites with the following limitation?
1. After combine, the number of samples of each new site should no less than 30;
2. After combine, the rate of each new site should be as closer to 3 as possible;

Use mathematical notation: $$\min\frac{\sum_{i=1}^N (n_i-3)^2}N, n_i\ge30$$
where $n_i$ is the number of samples of each new site and $N$ is the number of new sites.

Thanks in advance.