Closed HironobuHasegawa closed 2 years ago
Hello,
I sincerely apologize for my mistake. The offset had to be specified as a separate argument, not in the formula. I was confused with the usage of offset in lme4::glmer.
If possible, could you issue an error or warning when writing an incorrect formula? Also, it would be greatly appreciated if you could add an example using offset in the manual.
Thank you to all the developers.
Below is the code including the case where it works correctly.
library(lmerTest)
data("cake", package="lme4")
cake2 <- data.frame(cake,os = round(cake$temp/cake$angle,0))
(modelWithOffset <- lmer(angle ~ recipe * temp + (1|recipe:replicate), offset=os, cake2))
(modelWithoutOffset <- lmer(angle ~ recipe * temp + (1|recipe:replicate), cake2))
(modelWithError <- lmer(angle ~ recipe * temp + (1|recipe:replicate)+offset(os), cake2)) # No error and warning
anova(modelWithOffset)
anova(modelWithoutOffset)
anova(modelWithError)
difflsmeans(modelWithOffset)
difflsmeans(modelWithoutOffset)
difflsmeans(modelWithError) # Error, of course
Hello,
If the lmerTest::difflsmeans() function is applied to a mixed model with an offset term specified by the lmer() function, an error will occur if there is no object with the variable name specified by the offset.
Here's a simple example that reproduces the problem:
sessionInfo()
R version 3.6.3 (2020-02-29) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS 10.16 lmerTest_3.1-3 lme4_1.1-27.1Thanks