Björn Stollenwerk wrote: > # Hello R Users, > # > # I would like to fit a glm model with quasi family and > # logistical link function, but this does not seam to work > # with binary data. > # > # Please don't suggest to use the quasibinomial family. This > # works out, but when applied to the true data, the > # variance function does not seams to be > # appropriate. > # > # I couldn't see in the > # theory why this does not work. > # Is this a bug, or are there theoretical reasons? > # One problem might be, that logit(0)=-Inf and logit(1)=Inf. > # But I can't see how this disturbes the calculation of quasi-Likelihood. > # > # Thank you very much, > # best, > # > # Björn > > set.seed(0) > y <- sample(c(0,1), size=100, replace=T) > > # the following models work: > glm(y ~ 1) > glm(y ~ 1, family=binomial(link=logit)) > glm(y ~ 1, family=quasibinomial(link=logit)) > > # the next model doesn't work: > glm(y ~ 1, family=quasi(link=logit)) >
This is an issue with the starting values provided to glm. Take a look at the difference between: quasibinomial()$initialize and quasi("logit")$initialize and where this is used in glm.fit and you should see the why the error occurs. To avoid this, you can supply your own starting values from a call to glm mustart <- predict(glm(y ~ 1, binomial), type = "response") glm(y ~ 1, quasi("logit"), mustart = mustart) or just use: glm(y ~ 1, quasi("logit"), mustart = rep(0.5, length(y))) HTH, --sundar ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html