[R] glm

Thomas Lumley
Mon, 31 Jan 2000 17:01:32 -0000

On Mon, 31 Jan 2000, Keith Worsley wrote:

>        I've downloaded R for windows (9.0.1) and it is great! I've
> converted all my lecture notes for my GLM course to run on R (they are
> available on my web page below). I must admit I particularly like the
> default contrast options, which are identical to GLIM. Also I like the
> gl function - very useful! I have a couple of questions/bugs:
>
> 1. predict.glm doesn't work, but predict.lm does - actually all I am
> after is the equivalent of the GLIM

More precisely, predict.glm(,se.fit=T) doesn't work.

On line 36, change from
	type=type
to
	type=ifelse(type=="link","response",type)


>
>      $extract %vl
>
> command, which I want to get from
>
>      vl<-predict.glm(glm,se.fit=T)$se.fit^2
>
> A bit clumsy - is there a better way? I'm using it to calculate
> 'deleted' residuals:
>
>      resid(glm)/(1-vl/summary(glm)$dispersion)

I think rstudent() does what you want.

> 2. What are you actually using as an estimator of the dispersion
> parameter? Is it dev/df, or is it sum((Y-mu)^2/V(mu))/df?

It's the latter.  Look at summary.glm for the code

> 3. It would be very nice to be able to fix the dispersion parameter in
> advance, before using summary(glm). You might know that the data is
> exponential, in which case you want to fix the gamma dispersion
> parameter to 1, or you might have a previous value from another
> analysis, or you might want to cope with extra-binomial/poisson
> variation by using dev/df. Is there an easy way of doing this? In GLIM,
> you just say $cal %sc= ...

summary.glm() has a dispersion= option.


	-thomas

Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle