Re: [Rd] proposed simulate.glm method

From: Ben Bolker <>
Date: Thu, 12 Feb 2009 13:45:59 -0500

  Elsewhere (at least in lme4), refit(sim(model)) does the same thing [and so one would need something like apply(sim(model,1000),2,refit)].

  sim() is quite interesting, as is Zelig, but I'm not sure I am ready to leap to it yet -- this was basically a suggestion that simulate.glm could be included in "vanilla" R ...

  Also (for better or worse), it looks like sim() also does parametric bootstrapping on the parameter values, whereas simulate.[g]lm() just uses "plug-in" estimates.

    Ben Bolker

Alex D'Amour wrote:

> There is functionality similar to this included in the Zelig package
> with it's "sim" method. The "sim" method goes a step further and
> replicates the fitted model's analysis on the generated datasets as
> well. I would suggest taking a look -- Zelig supports most (if not
> all) glm models and a wide range of others.
> The Zelig maintainers' site can be found at:
> Full disclosure: I am an employee of the Institute for Quantitative
> Social Science, which performs most of the development and support for
> the Zelig package.
> Best,
> Alex D'Amour
> Statistical Programmer
> Harvard Institute for Quantitative Social Science
> 2009/2/12 Ben Bolker <>:

>> I have found the "simulate" method (incorporated
>> in some packages) very handy. As far as I can tell the
>> only class for which simulate is actually implemented
>> in base R is lm ... this is actually a little dangerous
>> for a naive user who might be tempted to try
>> simulate(X) where X is a glm fit instead, because
>> it defaults to simulate.lm (since glm inherits from
>> the lm class), and the answers make no sense ...
>> Here is my simulate.glm(), which is modeled on
>> simulate.lm . It implements simulation for poisson
>> and binomial (binary or non-binary) models, should
>> be easy to implement others if that seems necessary.
>> I hereby request comments and suggest that it wouldn't
>> hurt to incorporate it into base R ... (I will write
>> docs for it if necessary, perhaps by modifying ?simulate --
>> there is no specific documentation for simulate.lm)
>> cheers
>> Ben Bolker
>> --
>> Ben Bolker
>> Associate professor, Biology Dep't, Univ. of Florida
>> /
>> GPG key:
>> ______________________________________________
>> mailing list
Ben Bolker
Associate professor, Biology Dep't, Univ. of Florida /
GPG key:

______________________________________________ mailing list
Received on Thu 12 Feb 2009 - 17:48:29 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 13 Feb 2009 - 10:30:23 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive