[R-sig-ME] modifying the simulation in lme4

Boylan, Ross Ro@@@Boy|@n @end|ng |rom uc@|@edu
Fri Jun 14 07:05:23 CEST 2024


I want to do simulations using GLMM's from lme4, but not exactly what the current simulate() offers.
In particular I want to generate cluster random effects that are limited to various subsets of the real line.  So in effect the simulation takes some extra arguments.

Does anyone have any thoughts about the best way to approach this?

At the moment, it looks to me as if the simplest route is to copy the code (from predict.R, I think) and modify it, placing the result in my package.  This wouldn't track future changes in the lme4 code and generally violates Don't Repeat Yourself, but it doesn't seem there are good alternatives.  The parts I'm interested in changing are sections of the current code, including functions defined inside the main function, as well as functions internal to lme4.  These do not seem amenable to the monkey-patching methods I've read about in R, which generally involve inserting extra namespaces.  Since the functions are in the package namespace (or even have function scope), I can't intercept them.

The current simulate(), or, more accurately, the .simulateFun() it calls, does a large amount of bookkeeping getting everything in suitable form, and I would like to use that.

My cases of interest only have random intercepts, which of course means some of the code that deals with more complicated random effects is not necessary, at least initially.

Thanks.
Ross Boylan


	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list