Skip to content

Cannot grok the newdata argument in simulate.merMod(), package lme4

1 message · Ben Bolker

#
With apologies for delayed response.

   The answer to the "why doesn't roll-your-own match simulate()" is on 
Stack Overflow now: https://stackoverflow.com/a/73576691/190277. The 
short answer is that the differences are harmless and caused by 
differences in the procedures used to pick multivariate Normal deviates 
(which give the same *distributions*, just not the same specific values 
for any given realization/random number seed).

   The answer to "why doesn't simulate() + newdata do what I want" is 
simple **IF YOU KNOW THE ANSWER ALREADY**, which is that for binomial 
responses, the number of trials per observation needs to be specified 
somehow.  Your experience reflects arguably a bug in the code, the 
documentation, or the user interface design (or some combination), but 
the solution is to specify something like

   weights = rep(50, nrow(X))

if (for example) you want all of the binomial samples to be out of 50. 
Or whatever makes sense for your application.  (And good for you for 
paying attention to the "ominous warning"!)

   Hope that helps.

  cheers
    Ben Bolker
On 2022-08-05 2:10 a.m., Rolf Turner wrote: