Home › forums › Mixed Models › PostHoc Test with lsmeans error with uncorrelated random effects
Tagged: emmeans, lsmeans, posthoc test
This topic contains 1 reply, has 2 voices, and was last updated by henrik 1 year, 3 months ago.

AuthorPosts

March 23, 2018 at 10:00 GMT+0000 #213
Dear Henrik,
I have a simple model, a categorical predictor with 3 levels and find a sign. effect, and now want to test, where this effect comes from by using lsmeans::pairs (or ::contrast) posthoc tests (same happens with the “emmeans” package).
But when I run a mixed model (any dataset) with uncorrelated random intercepts and slopes, e.g.
mod1<mixed(y~x+(1+xsubjects), method=”LRT”, data=data, expand_re=TRUE)and afterwards do
lsm.options(lmer.df = “Satterthwaite”)
lsmeans(mod1, ~ x, data=mod1$data)I get the following error:
Error in eval(predvars, data, env) : Object ‘re1.x1’ not foundCan you please give me a hint, or is there an alternative? I need this post – hoc test desperately 🙂
Best, René
 This topic was modified 1 year, 3 months ago by René Sch..

March 24, 2018 at 19:28 GMT+0000 #217
One surprising solution (surprising in the sense that I only know about it for a few days) is to set
set_data_arg = FALSE
. In the current CRAN version (but not in the current development and next CRAN version), this throws quite a few errors which can be safely ignored.library("afex") data("Machines", package = "MEMSS") m1 < mixed(score ~ Machine + (MachineWorker), data=Machines, expand_re = TRUE, set_data_arg = FALSE) emm_options(lmer.df = "Satterthwaite") emmeans(m1, "Machine") # Machine emmean SE df lower.CL upper.CL # A 52.35556 2.397324 7.35 46.74094 57.97017 # B 60.32222 2.633283 9.04 54.36898 66.27546 # C 66.27222 2.836796 11.56 60.06544 72.47901 # # Degreesoffreedom method: satterthwaite # Confidence level used: 0.95
Alternatively, a different method for calculating the df can also be chosen:
m2 < mixed(score ~ Machine + (MachineWorker), data=Machines, expand_re = TRUE) emm_options(lmer.df = "Satterthwaite") emmeans(m2, "Machine") # Error in eval(predvars, data, env) : object 're1.Machine1' not found emm_options(lmer.df = "asymptotic") emmeans(m2, "Machine") # Machine emmean SE df asymp.LCL asymp.UCL # A 52.35556 2.397324 Inf 47.65689 57.05422 # B 60.32222 2.633283 Inf 55.16108 65.48336 # C 66.27222 2.836796 Inf 60.71220 71.83224 # # Degreesoffreedom method: asymptotic # Confidence level used: 0.95 emm_options(lmer.df = "kenwardroger") emmeans(m2, "Machine") # Machine emmean SE df lower.CL upper.CL # A 52.35556 2.397324 7.35 46.74087 57.97024 # B 60.32222 2.633283 9.04 54.36897 66.27548 # C 66.27222 2.836796 11.60 60.06746 72.47698 # # Degreesoffreedom method: kenwardroger # Confidence level used: 0.95
I am currently deliberating whether to use
set_data_arg = FALSE
as the new default. 
AuthorPosts
You must be logged in to reply to this topic.