From maechler at stat.math.ethz.ch  Fri Feb 13 21:27:57 2009
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Fri, 13 Feb 2009 21:27:57 +0100
Subject: [Rd] proposed simulate.glm method
In-Reply-To: <49959745.9040700@warwick.ac.uk>
References: <49944E5A.1020000@ufl.edu>
	<18837.19884.215746.626683@stat.math.ethz.ch>
	<49955E32.8010005@warwick.ac.uk>
	<18837.32301.604378.110374@stat.math.ethz.ch>
	<49959745.9040700@warwick.ac.uk>
Message-ID: <18837.55245.15158.29378@cmath-5.math.ethz.ch>

Thank you, Heather and Ben,

>>>>> "HT" == Heather Turner <Heather.Turner at warwick.ac.uk>
>>>>>     on Fri, 13 Feb 2009 15:52:37 +0000 writes:

    HT> Yes, thanks to Ben for getting the ball rolling. His
    HT> code was more streamlined than mine, pointing to further
    HT> simplifications which I've included in the extended
    HT> version below.

    HT> The code for the additional families uses functions from
    HT> MASS and SuppDists - I wasn't sure about the best way to
    HT> do this, so have just used :: for now.

    HT> It appears to be working happily for both glm and gnm
    HT> objects (no gnm-specific code used).

    HT> Best wishes,

    HT> Heather

[....]

I have now followed Brian Ripley's suggetion to just extend
simulate.lm() to also deal with "glm" objects, but using
Heather's suggestions for the different families;
I've just commited src/library/stats/R/lm.R  with the new code.
(get it from  svn.r-project.org/R/trunk/ or this night's R-devel
 tarball).

One difference to your propsal: Instead of just
    object$fitted , the code is using
    fitted(object)  ... something which should properly to the na.action
used.

For the (MASS and) SuppDists package requirement, I'm using 
the following

      if(is.null(tryCatch(loadNamespace("SuppDists"),
			  error = function(e) NULL)))
	  stop("Need CRAN package 'SuppDists' for 'inverse.gaussian' family")


I've not yet updated the help page for simulate(),
and have only tested relatively few cases for binomial, poisson
and Gamma.
I've wanted to expose this to you, so you can provide more
feedback and possibly even a patch to
   svn.r-project.org/R/trunk/src/library/stats/man/simulate.Rd

Martin



[Rd] proposed simulate.glm method
Martin Maechler