[R] Question about contrasts and interpreting glm output for factors

dhinds at sonic.net dhinds at sonic.net
Thu Aug 4 04:01:22 CEST 2011


I'm fitting a logistic regression model of the form:

  outcome ~ covariates + A*B

where A and B are factors -- A has 4 levels, B has 2 levels.  The A
and B term each have significant main effects and the interaction term
is significant.  I'd like to ask, how does a particular set of A and B
values affect the predicted outcome, compared to the mean prediction
across all levels.  The design is unbalanced but is essentially a
random sample of the underlying population, at least with respect to A
and B.  So I think what I'm asking for are contrasts for each
combination of A and B, against a weighted sum of regression
coefficients for all values of A and B.

I'm currently doing this with the 'rms' package using things like:

contrast(model, list(A=a0,B=b0),list(A=levels(A),B=levels(B)),
         type='average', weights=as.data.frame(table(A,B))$Freq)

where a0 is a particular level of A, and b0 is a level of B.

Is this a reasonable thing to do?  The results are fairly consistent
with what I get if I fit models where I replace the A*B term with a
indicator for a particular combination of levels of A and B, like 
I(A==a0 & B==b0), and use the Wald test on that term.  Any suggestions
for good information sources for using complex contrasts would also be
appreciated; I haven't found a great one so far.

-- Dave



More information about the R-help mailing list