I am trying to conduct a logistic modeling analysis. In this analysis, the data is as the following:
Y: binary (0,1)
And for the independent variables, they are as the following:
X1: DrugA: categorical variable. Did patients take Drug A ( yes or no)
X2: DrugA_Conc: continuous variable. the concentrations of Drug A which also includes zero.
X3: DrugB: categorical variable. Did patients take Drug B (yes or no).
Please note that in the input dataset, patients belong to one of 3 groups:
- Did NOT take either Drug A nor Drug B (placebo)
- Took Drug A but NOT Drug B (Drug A alone)
- Took Drug A and Drug B (combination)
Please see the code below that generates a representation of the independent variables dataset:
DrugA<-data.frame(DrugA=factor(1))
DrugA_Conc<-data.frame(DrugA_Conc=rep(seq(from = 0, to = 100, length.out = 3)))
DrugB<-data.frame(DrugB=factor(c(0,1)))
mergd<-merge(DrugA,DrugA_Conc)
mergd2<-merge(mergd,DrugB)
DrugA_2<-data.frame(DrugA=factor(0))
DrugA_Conc_2<-data.frame(DrugA_Conc=rep(0,length.out = 3))
DrugB_2<-data.frame(DrugB=factor(0))
mergd3<-merge(DrugA_2,DrugA_Conc_2)
mergd4<-merge(mergd3,DrugB_2)
mergd5<-rbind(mergd2,mergd4)
My question is the following: How can I code a logistic model in R to predict the effect of DrugA_Conc on Y with and without the presence of DrugB, and have the output predicted for the 4 possible scenarios ( the 3 listed above) +
- Did NOT take Drug A but took Drug B (Drug B alone).
I tried the following codes in R but it did not work:
m1 <- glm(Y~ DrugB+DrugA*DrugA_Conc, data=all, family="binomial")
m2 <- glm(Y~ DrugB+I(DrugA*DrugA_Conc), data=all, family="binomial")
Please note that I am not trying to evaluate the interaction between DrugA and DrugA_Conc but rather trying to create predictions for 4 possible drug combination scenarios ( Drug A alone, Both drugs, none of the drugs,Drug B alone) based on the dataset that has the first 3 scenarios.
Also, can the code be applied if I take the log of DrugA_Conc ( I mean log(DrugA_Conc)
)
In SAS, I found that a trick (multiplying DrugA*DrugA_Conc
) can be applied to code the model like the following, which allows for predicting the 4 scenarios (Figure 1):
model Y(event='1') = DrugB DrugA*DrugA_Conc/
Best regards,