jeudi 11 juillet 2019

R code for OR statement between treatment and control group

I'm running a logit regression to analyze grade completion during a given period. I'm trying to use the Pre period as my control group and the Post period as my treatment group. I want an "or" statement to compare the treatment with the control group. Basically I want R to run my glm if Pre==1 OR Post==1. All these variables are dummies.

I keep getting the error message "the condition has length > 1 and only the first element will be used the condition has length > 1 and only the first element will be used." What I'm understanding is that it's not taking both conditions into account.I have already tried the following:

Grd7<-glm(Grade7~Intensity*Post,if((Pre|Post==1)),family="binomial")
if((Pre==1)|(Post==1))
if(1 %in% c(Pre,Post))
if(any(Pre==1)|any(Post==1))

I expect the results to be different when including the if statement in comparison to without it. However, I keep getting the same result in both cases.

Aucun commentaire:

Enregistrer un commentaire