I am somewhat new to R and trying to polish my logistic regression. I am testing if my risk factors(cruise, age, sex, and year) have a significant effect on my dependent variable, MPS infection (named MPS_BINARY). I have a total of four cruises (5, 7, 9, 11), three years, thirteen ages, and two sexes (1 or 0).
I am able to run the full model with the following command:
>mylogit<-glm(MPS_BINARY~ AGE * SEX * CRUISE * YEAR, data=mps,family="binomial")
From this I have my p-values, I can now identify significant risk factors and interactions. My data shows a significant p-value for the interaction between cruise 7 and year. Following backwards selection, I now need to run the model again with my original risk factors and significant terms. I am having increasing difficulty isolating cruise 7 from my cruise data to run as an interaction with year. I have tried using the command:
>mylogit<-glm(MPS_BINARY~AGE+SEX+YEAR+CRUISE+mps$CRUISE7*YEAR,data=mps,family="binomial")
But this, of course, does not recognize cruise 7 and I receive the error message: Error in model.frame.default(formula = MPS_BINARY ~ AGE + SEX + CRUISE + : invalid type (NULL) for variable 'mps$CRUISE7'.
My question is how can I run my logistic regression with all of my risk factors, and the significant interaction between year and cruise 7? I cannot figure out how to isolate only cruise 7 for the interaction with year. Please let me know if you need more information, thank you!
~AGE+SEX+YEAR+CRUISE
) and then allow an interaction between cruise anf year (~AGE+SEX+CRUISE7*YEAR
) and examine the if this results in a chnage in the deviance (useanova(mod1, mod2)
$\endgroup$~AGE+SEX+CRUISE*YEAR
$\endgroup$