I am trying to predict child nutrition (binary) using a set of variables. The two that I want to interact are maternal education (none, primary, middle, HS) and wealth quintile (1,2,3,4,5). Thus far I tried:

form <- nutrition ~ maternal_ed + wealth_q + maternal_eq * wealth_q + other_covars
model.results <- glm(form, data=d, family=quasibinomial)

I am only getting one value in model.results for the interaction, which reads 'mat_ed_level:wealth_q'. I am unsure how to use or interpret this value. I am somewhat unfamiliar with the use of interaction terms, so any information about the interpretation of the (correct) output would be greatly appreciated. Thanks,

  • $\begingroup$ Does R know wealth quintile is a factor? $\endgroup$ – mnel Nov 30 '12 at 1:30
  • $\begingroup$ Not sure what you mean -- how would I specify that? Right now, they are both numeric with values 1,2,3,4 and 1,2,3,4,5 $\endgroup$ – mike Nov 30 '12 at 1:40

From your comments, it appears that you have not specified to R that these two variables are categorical. (factor variables in R). Given they have the appearance of numeric (continuous) variables, R will assume they are, and fit the model as if they were continuous.

To convert to factor variables (with your data.frame d)

d$wealth_q <- factor(d$wealth_q)
d$maternal_q <- factor(d$maternal_q)

Also, your formula is somewhat redundant

~maternal_eq * wealth_q expands to main effects + interactions

So the following should work

form <- nutrition ~ maternal_eq * wealth_q + other_covars
model.results <- glm(form, data=d, family=quasibinomial)
| cite | improve this answer | |
  • 1
    $\begingroup$ Thanks for the response -- is there any drawback to defining the categories are factors if they are ordered and (likely) equidistant from one another? $\endgroup$ – mike Nov 30 '12 at 1:58
  • 2
    $\begingroup$ I think not defining them as factors would be far more dangerous Do you expect the effect comparing no education to primary to be the same as comparing middle to high school and exactly half the effect of comparing primary and high school. They are categorical data, not continuous, so you need to code them as such and model appropriately. You could go down the path of ordered factors if you wished, but I think that would add more assumptions to your model $\endgroup$ – mnel Nov 30 '12 at 2:07
  • 1
    $\begingroup$ R also has "ordered factors" for handling this sort of case. I don't believe that glm treats ordered factors differently from regular factors, but other regression packages (such as gbm) do. Ordered factors are described on this page. $\endgroup$ – David J. Harris Nov 30 '12 at 7:56
  • 1
    $\begingroup$ @PeterFlom There is a package gbm. $\endgroup$ – Roland Nov 30 '12 at 21:18
  • 1
    $\begingroup$ @PeterFlom ?? searches only the help files of installed packages. It would find package names (try ??ggplot2, which you probably have installed). You could have used RSiteSearch('gbm'). $\endgroup$ – Roland Dec 3 '12 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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