Forum Replies Created
-
AuthorPosts
-
statmerkur
ParticipantEDIT (I don’t know how I can edit or delete my question?!): I realized that this is a broader question that is not directly related to
lmer_alt
but more so tolmer
and mixed models in general. So I decided to post it on CrossValidated.April 13, 2018 at 10:39 GMT+0000 in reply to: Why contr.sum for random effects grouping factors? #237statmerkur
ParticipantOK, so
mixed
converts treatment coded random effects grouping factors to sum coded factors (viacontr.sum
) just by convention?April 11, 2018 at 21:38 GMT+0000 in reply to: Why contr.sum for random effects grouping factors? #235statmerkur
ParticipantThanks, that cleared things up for me.
What I still don’t understand is in which case the coding for the random-effects grouping factors does make a difference. Can you please give an (R code) example for this situation?April 10, 2018 at 22:33 GMT+0000 in reply to: Why contr.sum for random effects grouping factors? #232statmerkur
ParticipantThere seems to be no difference between models with different coding schemes for the random-effects grouping factors, i.e.
m1
=m2
andm3a
=m4a
. Hence I don’t understand whyafex
setscontr.sum
for the random-effects grouping factors (Worker in the example below).Besides that, AFAIU,
m3b
andm4b
are models where random slopes are coded differently (treatment coding vs sum coding) and they seem to estimate the same random effects which in turn are the same asm5
s (which also suppresses the fixed intercept) estimates for the random effects.Why is that?
library(afex) data("Machines", package = "MEMSS") m1<- mixed(score ~ Machine + (Machine|Worker), Machines) contrasts(Machines$Machine) <- contr.sum(length(levels(Machines$Machine))) m2 <- mixed(score ~ Machine + (Machine|Worker), Machines, check_contrasts = F) m1$full_model # Machine sum coded + Worker sum coded m2$full_model # Machine sum coded + Worker treatment coded contrasts(Machines$Machine) <- contr.treatment(length(levels(Machines$Machine))) m3a <- mixed(score ~ Machine + (Machine|Worker), Machines, check_contrasts = F) m3b <- mixed(score ~ Machine + (0 + Machine|Worker), Machines, check_contrasts = F) contrasts(Machines$Worker) <- contr.sum(length(levels(Machines$Worker))) m4a <- mixed(score ~ Machine + (Machine|Worker), Machines, check_contrasts = F) m4b <- mixed(score ~ Machine + (0 + Machine|Worker), Machines) m5 <- mixed(score ~ 0 + Machine + (0 + Machine|Worker), Machines, check_contrasts = F) m3a$full_model # Machine treatment coded + Worker treatment coded m4a$full_model # Machine treatment coded + Worker sum coded m3b$full_model # Machine treatment coded + Worker treatment coded + random intercept suppressed m4b$full_model # Machine sum coded + Worker sum coded + random intercept suppressed m5$full_model # Machine treatment coded + Worker sum coded + fixed and random intercept suppressed
April 9, 2018 at 20:57 GMT+0000 in reply to: Why contr.sum for random effects grouping factors? #227statmerkur
ParticipantI was just curious whether there was a specific reason for that. So, would you agree that using orthogonal contrasts for categorical covariates and, say, treatment coding for random effects grouping factors is equivalent to using orthogonal contrasts for both categorical covariates and random effects grouping factors?
statmerkur
ParticipantI am indeed interested in the individual parameters as I have specific hypotheses for different a priori contrasts. Maybe using
contr.sum()
was not the best example to illustrate this. But thanks for reminding me on the fact thatafex
is designed to provide tests of (main-)effects – it now became clear to me that using your package for this purpose seems to be inappropriate. However, when I useset_data_arg = FALSE
I still get the same results.statmerkur
ParticipantThis makes perfect sense and I can think of both situations where using
lsmeans
would be useful and where it wouldn’t. So in case of unequal cell sizes, should the dependent t-tests still match theSPSS
sEMMEANS
or how can one do an equivalent analysis in R then?statmerkur
ParticipantYes, it only appears if I use the
HF
. I didn’t know that epsilon can be above 1 – thanks for the hint.statmerkur
ParticipantThank you again for explaining the issue in a very comprehensible way!
statmerkur
ParticipantThanks for this detailed answer!
You state that the fits are the same as long as one usesREML = FALSE
. Why would the results be different if one usedREML = TRUE
?statmerkur
ParticipantYes, that made it clear! Thanks.
-
AuthorPosts