I am doing an analysis in which I use generalized linear modelling. I need to know if there is any interaction of the predictors.Also, I am interested to know in what way the individual levels affect the colour.

My first doubt is can we consider categorical and numerical variables together as predictors in glm?

My response variable is two colours, and the predictors have two continuous variables, weight(W) and time in days (T). Other predictors are categorical. my starting model is involving interaction in all five factors.

model1<- glm(C~H*P*W*S*T, family=binomial, data=s1)

When I run this command, there is a warning message displayed, fitted probabilities 0 or 1 occurred. should I go ahead in spite of this warning. after this step, I did

anova(model1, test="Chisq")

then I removed each non significant term and reached a stage where only three factors independently affect the response variable.

finalmodel<- (C~H+P+T)

is the likelihood ratio test sufficient to tell me about the fit of this model because I do get a significant chi squared if i remove any of these terms?

anova(finalmodel, finalmodel-H/P/T, test='LRT')

Lastly if we need to do the post hoc using glht for pair wise comparison

ph1<- glht(finalmodel, mcp(H="Tukey"))$linfct
    ph2<- glht(finalmodel, mcp(P="Tukey"))$linfct
summary(glht(finalmodel,linfct=rbind(ph1, ph2)))

is this the right way to find out pair wise comparisons. Also, i could not include the third term , T because there was a message saying it is not a factor and all the time it was appearing in blue ink on the screen.


1 Answer 1


First, there is no reason you cannot have both categorical and numeric variables in a glm.

Second, if you want to investigate interactions, you should do so, but your first model includes all 2, 3, 4 and 5 way interactions. This is almost certainly overfit and is probably not what you want to investigate. 4 and 5 way interactions are very very hard to interpret and theory probably does not suggest general interactions of this kind, although it may suggest some particular one.

Third, your strategy of deleting nonsignificant variables from the model is a common one; it amounts to a manual backwards selection. Backwards selection has many problems which have been discussed here many times; doing it manually is better that automated, but only if you do more that what you did - that is, if you use substantive knowledge in addition to statistical criteria and if you make a provision (e.g. by some validation method) for the problem of fitting the sample too much.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.