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 $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) 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? 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= ... 4. I don't think AIC is stricly correct. My understanding of AIC is that it is the log likelihood maximised over all the parameters, including the dispersion parameter. Now the problem is that the mle of the dispersion parameter for the gamma family (and the exponential family in general) is really awkward - I think it has to be found by interative methods, using the derivative of the gamma function - I see from a print of Gamma that you are using dev/n, but I don't think this is the mle.... 5. As a matter of interest, section 9.1 of my notes defines the poisson-expoential family, with a variance function mu^(3/2), useful for continuous data with exact zeros. I coded up the family by modifying the poisson family - seems to work, giving the same values as GLIM, but again I had to leave AIC blank because it's too awkward to estimate the dispersion parameter.... Keith Worsley Department of Mathematics and Statistics McGill University office: BH 1232 805 ouest, rue Sherbrooke tel: (514)-398-3842 Montreal fax: (514)-398-3899 Quebec e-mail: worsley at math.mcgill.ca Canada H3A 2K6 web: http://www.math.mcgill.ca/keith -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 GLIMMore 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 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 4. I don't think AIC is stricly correct. My understanding of AIC is that > it is the log likelihood maximised over all the parameters, including > the dispersion parameter. Now the problem is that the mle of the > dispersion parameter for the gamma family (and the exponential family in > general) is really awkward - I think it has to be found by interative > methods, using the derivative of the gamma function - I see from a print > of Gamma that you are using dev/n, but I don't think this is the mle....Yes you are right. I chose this only as a reasonable approximation for the gamma and inverse Gaussian distributions. If you want the exact AIC, you can get it from the gnlr function in my gnlm library. Jim -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._