# Creating hypothetical logistic regression models for sequential covariate adaptive randomization

I'm about to run a clinical trial and I would like to allocate participants to the active treatment group versus the control group while avoiding imbalances in baseline chracteristics or prognostic factors. In other words: avoid that samples are significantly different at baseline.(http://www.ncbi.nlm.nih.gov/pubmed/12505244)

By design the experiment will have participants coming in two people sequentually at a time where either participant should be allocated to treatment or control group. Assesment of baseline characteristics happens before allocation, and it's these characteristics I desire to minimize. I've looked into automated programs that can do this in a blinded fashion, but these options usually collapse continous variables into categorical variables (http://www.scirp.org/journal/PaperInformation.aspx?PaperID=8518).This goes against findings of more balance when using continuous variables instead collapsing into categorical variables. (http://www.ncbi.nlm.nih.gov/pubmed/16807130) So this is what I want to do.

So lets say I have a dataset like so: where 2 participants are already allocated randomly. Where group 1 is active, and the x1 variable is a prognostic variable that ideally will end up similar in both groups:

df <- data.frame(ID = c(2,3,4,5,6,7),x1=c(10.00,9.18,8.92,10.07,8.88,8.68),sex=c(0,1,0,0,0,1),group=c(1,0,NA,NA,NA,NA))
enrolled = 4;allocated = 2
curdf <- df[1:enrolled,]
> curdf
ID   x1 sex group
1  2 10.0   0     1
2  3  9.2   1     0
3  4  8.9   0    NA
4  5 10.1   0    NA


From the plot, it is obvious that allocating the "even numbered" participant (=4), to the active group, and therefore the "odd numbered"(=3) to control would be optimal for minimizing differences between the two groups.

Question 1: Is there an ideal technique that can perform this decision automatically?

I thought it best to construct two hypothetical allocations. I term these the Even and Odd Hypothesis, e.i either Even is allocated to Active, or as in the Odd hypothesis, Odd is allocated to active. I then model the two different scenarios with logistic regression, where treatment allocation is the outcome and pretreatment variables are regressors.

Here I reasoned that one of the models would be worse in the sense that it explained less variance (e.i predicted treatment allocation worse) and thus this model would be optimal in the sense that this would lead to minimization between groups.

For this next question I only use one regresor at a time (I will get to that later) in R the Even Hypothesis looks like this:

curdf$group[allocated + 1] <- 1;curdf$group[allocated + 2] <- 0;curdf$group <- as.numeric(curdf$group)
evendf <- curdf;
EvenModel <- glm(group ~ x1,family=binomial(link="logit"), data=evendf)
#and the odd Hypothesis looks like this:
curdf$group[allocated + 1] <- 0;curdf$group[allocated + 2] <- 1
odddf <- curdf
OddModel <- glm(group ~ x1,family=binomial(link="logit"), data=odddf)


looking at the coefficient z value for x1 I see that the absolute value is lower in the case of the OddModel (where the Odd is allocated to Active), meaning that the OddModel explains less variance, and is thus the optimal choice for a minimization of pretreatment variable predicability of allocation. But that runs against the descriptive finding.

> summary(OddModel)$coefficients Estimate Std. Error z value Pr(>|z|) (Intercept) -550.8 1296897 -0.000425 1 x1 57.4 135488 0.000424 1 > summary(EvenModel)$coefficients
Estimate Std. Error z value Pr(>|z|)
(Intercept)    6.323      19.35   0.327    0.744
x1            -0.663       2.02  -0.327    0.743


I Then noticed that the two models have different intercepts and reasoned that I might need to control for that difference.

EvenModel <- glm(group ~ 0 + x1,family=binomial(link="logit"), data=evendf)
OddModel <- glm(group ~ 0 +  x1,family=binomial(link="logit"), data=odddf)
> summary(OddModel)$coefficients Estimate Std. Error z value Pr(>|z|) x1 0.0108 0.105 0.103 0.918 > summary(EvenModel)$coefficients
Estimate Std. Error z value Pr(>|z|)
x1 -0.00181      0.105 -0.0173    0.986


Here the "EvenModel" is shown to explain less variance and thus being more optimal for allocation to ensure minimization. I've tried generating other datasets to compare "removing the intercept" versus not, and removing it always produces the desired result. It's been discussed elsewhere whether it is "ok" to remove the intercept "When is it ok to remove the intercept in a linear regression model?"

This leads to Question 2: is this an instance where not modelling the intercept would be "ok" ?

Lastly I wish for this method to make the decision based on more than one variable. Lets try sex/gender for example:

Here I enroll more participants

df$group[allocated + 1] <- 1;df$group[allocated + 2] <- 0 # 4th and 5th allocated
enrolled = 6;allocated = 4; curdf <- df[1:enrolled,]
> curdf
ID    x1 sex group
1  2 10.00   0     1
2  3  9.18   1     0
3  4  8.92   0     1
4  5 10.07   0     0
5  6  8.88   0    NA
6  7  8.68   1    NA


Here, the difference between the two participants on the x1 variable is very small. Although with the sex variable,there is a female (1) in the two to-be-allocated subjects. And ideally we would want that female into the active group, as the control group already has one.

I create regression models for both variables and both hypothetical allocations

curdf$group[allocated + 1] <- 1;curdf$group[allocated + 2] <- 0;curdf$group <- as.numeric(curdf$group)
evendf <- curdf;
EvenModel_x1 <- glm(group ~ 0 + x1,family=binomial(link="logit"), data=evendf)
EvenModel_sex <- glm(group ~ 0 + sex,family=binomial(link="logit"), data=evendf)
#and the odd Hypothesis looks like this:
curdf$group[allocated + 1] <- 0;curdf$group[allocated + 2] <- 1
odddf <- curdf
OddModel_x1 <- glm(group ~ 0 + x1,family=binomial(link="logit"), data=odddf)
OddModel_sex <- glm(group ~ 0 + sex,family=binomial(link="logit"), data=odddf)


On the x1 variable the EvenModel is more optimal for minimization

> o_x1<- summary(OddModel_x1)$coefficients[3];o_x1 [1] -0.0233 > e_x1 <- summary(EvenModel_x1)$coefficients[3];e_x1
[1] -0.0057


But regarding the sex variable, the OddModel is more optimal

> o_sx <- summary(OddModel_sex)$coefficients[3];o_sx [1] 0.000000000000000222 > e_sx <- summary(EvenModel_sex)$coefficients[3];e_sx
[1] -0.00257

> (abs(o_x1) + abs(o_sx)) - (abs(e_x1) + abs(e_sx))
[1] 0.015


However when I combine them, subtracting the EvenModel from the OddModel, it still indicates the the EvenModel is better, even though that would mean dramatic difference the sex variable between groups.

I guess one solution might be to weight the factors differently, making the explained variance on the sex factor more important.

> (abs(o_x1) + (abs(o_sx)*10)) - (abs(e_x1) + (abs(e_sx)*10))
[1] -0.00818


But that just seems a bit arbitrary.

Question 3: Am I missing an obvious option to minimize across covariates?

After some speculation I reasoned that the undesireable favoring of the x1 variable of the sex variable was due to the variables not being normalized.

I found that normalizing each value as the amount of standard deviation from the mean solved the trick:

curdf$x1 <- (curdf$x1 - mean(curdf$x1)) / sd(curdf$x1)
curdf$sex <- (curdf$sex - mean(curdf$sex)) / sd(curdf$sex)
> curdf
ID    x1   sex group
1  2  1.19 -0.65     1
2  3 -0.18  1.29     0
3  4 -0.61 -0.65     1
4  5  1.30 -0.65     0
5  6 -0.68 -0.65    NA
6  7 -1.01  1.29    NA


I am still very much in doubt about question 1 and 2, E.i is there a better way to perform covariate adaptive randomization?. and is this an instance where removing the modelling of the intercept reasonable. I think I've solved the problem by just playing around and I'm not sure i did it for any valid reasons that I can explicitly explain.