[R-lang] Helmert contrast and goodness of fit

T. Florian Jaeger tiflo at csli.stanford.edu
Tue Jun 16 09:59:25 PDT 2009


Dear Claire,

I am working on a lmer regression. I have two modality factors (factors A
> and B), and one that has four levels (factorC). For this factor, I want to
> compare level 1 with level 2, then level 1 with 3 and level 1 with 4.


That is not a helmert contrast. A helmert contrast compares the mean for
each level of a factor against the mean of all subseqequent levels (a
reverse helmert contrast would compare to the mean of the preceding levels).
what you're doing could be done with treatment or contrast coding.

>
>
> model = lmer(DV ~ factorA + factorB + factorC +  factorA*factorC  +
> (1|Corpustext), data=corpus, family="binomial",contrasts = list(factorC =
> "contr.helmert"))
>
> - I've included helmert contrast in the model, but how can I make sure that
> the contrasts are the ones I intended?


you can define the order of the levels and hence which ones will be compared
with which ones by

factor(factorC, levels=c('c','a','b')   or however you want to order them.

- If the interaction between factorA and factorC is not significant for one
> contrast, shall I remove this contrast (then, how can I do that) or keep it
> in the final model?


I would keep it unless you have problems fitting an adequate model due to
data sparsity (overfitting). *If *you want to remove any interactions, you
have to recode factorC into separate variables (i.e. do the coding manually,
resulting in 3 new variables instead of factorC: factorC1vs2, factorC1vs3,
factorC1vs4), so that you can remove the interaction for only some of the
contrasts.

>
>
> Finally, when I check my actual final model with the somers2 function, I
> get the following values:
>          C         Dxy           n     Missing
>   0.769677    0.539354 1311.000000    0.000000
> - Is my model properly fitted? (I know a Dxy of 1 is a perfectly fit model)


I don't use this function, but my understanding is that the Dxy is an
attempt to have an R-square like pseudo measure for logit models. so, it
looks ok to me. But note that these measures do not show you whether a model
is appropriately fitted. For that you should conduct model evalutation. The
slides on the WOMM pages contains a section on that (the JaegerKuperman
slides).

Florian

>
>
> Many thanks for your help.
>
> Claire Delle Luche
>
> Laboratoire Dynamique du Langage
> 14, avenue Berthelot
> 69007 Lyon
> France
>
> _______________________________________________
> R-lang mailing list
> R-lang at ling.ucsd.edu
> http://pidgin.ucsd.edu/mailman/listinfo/r-lang
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://pidgin.ucsd.edu/pipermail/r-lang/attachments/20090616/f07edab8/attachment.htm>


More information about the R-lang mailing list