[Rd] proposed simulate.glm method
maechler at stat.math.ethz.ch
Fri Feb 13 11:38:36 CET 2009
>>>>> "BB" == Ben Bolker <bolker at ufl.edu>
>>>>> on Thu, 12 Feb 2009 11:29:14 -0500 writes:
BB> I have found the "simulate" method (incorporated
BB> in some packages) very handy. As far as I can tell the
BB> only class for which simulate is actually implemented
BB> in base R is lm ... this is actually a little dangerous
BB> for a naive user who might be tempted to try
BB> simulate(X) where X is a glm fit instead, because
BB> it defaults to simulate.lm (since glm inherits from
BB> the lm class), and the answers make no sense ...
BB> Here is my simulate.glm(), which is modeled on
BB> simulate.lm . It implements simulation for poisson
BB> and binomial (binary or non-binary) models, should
BB> be easy to implement others if that seems necessary.
BB> I hereby request comments and suggest that it wouldn't
BB> hurt to incorporate it into base R ... (I will write
BB> docs for it if necessary, perhaps by modifying ?simulate --
BB> there is no specific documentation for simulate.lm)
BB> Ben Bolker
thank you for your proposals.
I agree that simulate.glm() has been in missing in some way,
till now, in particular, as, as you note, "glm" objects extend
"lm" ones and hence simulate(<glm>, ...) currently dispatches to
calling simulate.lm(....) which is only correct in the case of
the gaussian family.
I have looked at your proposal a bit, already "improved" the
code slightly (e.g. re-include the comment you lost when you
``copied'' simulate.lm(): In such cases, please work from the
source, not from what you get by print()ing
stats:::simulate.lm --- the source is either a recent tarball,
or the SVN repository, in this case, file
and am planning to look at your and some own examples;
all with the goal to indeed include this in the R standard
'stats' package in R-devel [to become R 2.9.0 in the future].
About the help page: At the moment, I think that only a few
words would need to be added to the simulate help page,
and will be happy to receive a patch against this file.
Thank you again, and best regards,
Martin Maechler, ETH Zurich
More information about the R-devel