# How to compare before and after evolutions of a binary variable between two groups of treatment

Here is what look like my data

Groupe <- c(rep("A", 7), rep("B", 7))

DiabeteBeforeTreatment<-c(
"no", "yes", "yes", "yes", "no", NA, NA,
NA, "no", "yes", "yes", "yes", "no",
"yes")

DiabeteAfterTreatment <- c(
"no", "no", "no", NA, NA, "yes", "no", NA,
"yes", "yes", "yes", NA, "no", "yes")

mydata <- data.frame(Groupe,
DiabeteBeforeTreatment,
DiabeteAfterTreatment)


I want to compare whether one treatment improves diabetes better than another treatment. I have mixed cases before the treatment started: Some are diabetic and some are not. After treatment, patients may have different outcome possibilities, either they get better from their diabetes, they stay the same, or they get worse, i.e. they go from not having diabetes to having diabetes.

I am wondering what kind of statistical test I could use to compare the two treatments and determine whether one treatment improves the patient's condition better than the other.

Do I need to take into account the matching of the data in the analysis? Then I use a McNemar test. In this case, I would only do the analyses on patients who have before and after values (as I do not intend to impute).

Or I could use all patients in the analysis and calculate the number of yes and no in each group, after and before treatment, and compare the effectiveness between the groups without considering matching. I will only compare proportions of yes a each period between the treatment groups

I thought of another method, but only involving patients with two values, which is to create a score for each patient: If the patient goes from no to yes (that is worsening) the score will be -1, when he/she remains static the score will be 0 when going from yes to no (that is improvement) the score will be 1. Then I will compare the average of the scores between the two groups

What are the advantages and disadvantages of each of these methods? What could be their biases?

• In this example, you only have 3 complete cases for treatment A and 5 for treatment B. Is that typical of your data? That's a very high percentage of missing data, with its associated risk of bias from restricting to complete-data cases, and probably too few remaining cases for reliable results.
– EdM
Apr 27, 2022 at 13:23
• @EdM it is just a representation of my dataset. It doesn't reflect the frequency of missing value in real dataset, but my dataset actually contains missing data before and after treatment Apr 27, 2022 at 13:28

a logistic regression model to those pairs alone, using artificial response $$y^* =1$$ when $$(y_{i1} = 0, y_{i2} = 1)$$, $$y^* =0$$ when $$(y_{i1} = 1, y_{i2} = 0)$$, no intercept, and predictor values $$x^*$$.
Here, $$y_{i1}$$ and $$y_{i2}$$ are the outcomes (diabetes status in your case) for individual $$i$$ at times 1 and 2, respectively. A predictor value $$x^*$$ is the difference in predictor values between the two time points, $$x_i^* = x_{i2}-x_{i1}$$. In your situation with two treatment groups, you code that with a single binary predictor.