From Claire.Delleluche at univ-lyon2.fr Tue Jun 16 02:49:34 2009 From: Claire.Delleluche at univ-lyon2.fr (Claire Delle Luche) Date: Tue, 16 Jun 2009 11:49:34 +0200 (CEST) Subject: [R-lang] Helmert contrast and goodness of fit Message-ID: <19970451.56815.1245145775333.JavaMail.root@co7> Dear R users, 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. 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? - 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? 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) Many thanks for your help. Claire Delle Luche Laboratoire Dynamique du Langage 14, avenue Berthelot 69007 Lyon France From tiflo at csli.stanford.edu Tue Jun 16 09:59:25 2009 From: tiflo at csli.stanford.edu (T. Florian Jaeger) Date: Tue, 16 Jun 2009 12:59:25 -0400 Subject: [R-lang] Helmert contrast and goodness of fit In-Reply-To: <19970451.56815.1245145775333.JavaMail.root@co7> References: <19970451.56815.1245145775333.JavaMail.root@co7> Message-ID: <38dc9be90906160959v699b809dx71fa2eb378bd88ed@mail.gmail.com> 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: